diff --git a/lib/rules/headers/dl.js b/lib/rules/headers/dl.js index de15c1dfa..26f0f3120 100644 --- a/lib/rules/headers/dl.js +++ b/lib/rules/headers/dl.js @@ -92,7 +92,7 @@ exports.check = function (sr, done) { "\\/(\\d{4})\\/" + (sr.config.status || "[A-Z]+") + "-(.+)-(\\d{4})(\\d\\d)(\\d\\d)\\/?$"; - var matches = ($linkThis.attr("href") || "").match(new RegExp(vThisRex)) + var matches = ($linkThis.attr("href") || "").trim().match(new RegExp(vThisRex)) , docDate = sr.getDocumentDate() ; if (matches) { @@ -121,7 +121,7 @@ exports.check = function (sr, done) { if (!$linkLate || !$linkLate.length || $linkLate.attr("href") !== $linkLate.text()) err("latest-link"); var lateRex = "^https?:\\/\\/www\\.w3\\.org\\/" + topLevel + "\\/(.+?)\\/?$" - , matches = ($linkLate.attr("href") || "").match(new RegExp(lateRex)); + , matches = ($linkLate.attr("href") || "").trim().match(new RegExp(lateRex)); if (matches) { var sn = matches[1]; latestURI = $linkLate.text(); @@ -136,7 +136,7 @@ exports.check = function (sr, done) { if (!$linkPrev || !$linkPrev.length || $linkPrev.attr("href") !== $linkPrev.text()) err("previous-link"); var prevRex = "^https?:\\/\\/www\\.w3\\.org\\/" + topLevel + "\\/\\d{4}\\/[A-Z]+-(.+)-\\d{8}\\/?$" - , matches = ($linkPrev.attr("href") || "").match(new RegExp(prevRex)) + , matches = ($linkPrev.attr("href") || "").trim().match(new RegExp(prevRex)) ; if (matches) { var sn = matches[1]; @@ -151,7 +151,7 @@ exports.check = function (sr, done) { var $linkResc = dts.Rescinds.dd.find("a").first(); if (!$linkResc || !$linkResc.length || $linkResc.attr("href") !== $linkResc.text()) err("rescinds-link"); - var matches = ($linkResc.attr("href") || "").match(/^https?:\/\/www\.w3\.org\/TR\/\d{4}\/REC-(.+)-\d{8}\/?$/); + var matches = ($linkResc.attr("href") || "").trim().match(/^https?:\/\/www\.w3\.org\/TR\/\d{4}\/REC-(.+)-\d{8}\/?$/); if (matches) { var sn = matches[1]; if (sn !== shortname) err("this-rescinds-shortname"); diff --git a/test/all-rules.js b/test/all-rules.js index 214444a60..17f7166f7 100644 --- a/test/all-rules.js +++ b/test/all-rules.js @@ -75,6 +75,7 @@ var tests = { , errors: ["headers.dl", "headers.dl", "headers.dl", "headers.dl", "headers.dl", "headers.dl"] , warnings: ["headers.dl"] } , { doc: "headers/wrong-urls.html", errors: ["headers.dl", "headers.dl"], config: { previousVersion: true, status: "WD" } } + , { doc: "headers/dl-trailing-whitespace.html", config: { previousVersion: true, status: "WD" }, errors: ["headers.dl"] } ] , "h2-status": [ { doc: "headers/simple.html", config: { longStatus: "Working Draft" } } diff --git a/test/docs/headers/dl-trailing-whitespace.html b/test/docs/headers/dl-trailing-whitespace.html new file mode 100644 index 000000000..02f137815 --- /dev/null +++ b/test/docs/headers/dl-trailing-whitespace.html @@ -0,0 +1,86 @@ + + + + + Simple baseline headers valid document + + + + + +
+ + W3C + +

Simple baseline headers valid document

+

W3C Working Draft 15 March 2017, edited in place 01 April 2014

+
+
This Version:
+
http://www.w3.org/TR/2017/WD-specberus-20170315/
+
Latest Version:
+
http://www.w3.org/TR/specberus/
+
Previous Version:
+
http://www.w3.org/TR/2017/WD-specberus-20170312/
+
Editor:
+
Specberus The Cranky
+
+ +
+
+

Abstract

+

+ We are the internets! +

+

Status of This Document

+

This section describes the status of this document at the time of its publication. + Other documents may supersede this document. A list of current W3C publications and the + latest revision of this technical report can be found in the + W3C technical reports index at + http://www.w3.org/TR/.

+

+ If you wish to make comments regarding this document, please send them to + public-html@w3.org + (subscribe, + archives). +

+

+ It's a valid test! +

+

+ Publication as a Working Draft does not imply endorsement by the W3C Membership. This is a + draft document and may be updated, replaced or obsoleted by other documents at any time. It is + inappropriate to cite this document as other than work in progress. +

+

+ This document was produced by a group operating under the + 5 February 2004 + W3C Patent Policy. + W3C maintains a + public list of + any patent disclosures made in connection with the deliverables of the group; that page + also includes instructions for disclosing a patent. An individual who has actual knowledge of + a patent which the individual believes contains + Essential + Claim(s) must disclose the information in accordance with + section 6 of the + W3C Patent Policy. +

+

Table of Contents

+ + +