diff --git a/docker/customHtmlRules.js b/docker/customHtmlRules.js index 14a033ae..223a5196 100644 --- a/docker/customHtmlRules.js +++ b/docker/customHtmlRules.js @@ -320,7 +320,7 @@ exports.addCustomHtmlRule = async (apiToken, url) => { var tagName = event.tagName.toLowerCase(), mapAttrs = parser.getMapAttrs(event.attrs); if (tagName === "a") { - if (mapAttrs["href"]) { + if (mapAttrs["href"] && mapAttrs["href"] !== "/") { if ( mapAttrs["href"].substr(mapAttrs["href"].length - 1) === "/" || mapAttrs["href"].substr(mapAttrs["href"].length - 1) === "." diff --git a/docker/test/html-rules-testing/url-must-be-formatted-correctly.spec.js b/docker/test/html-rules-testing/url-must-be-formatted-correctly.spec.js index 74d3dee1..3b5e3d6f 100644 --- a/docker/test/html-rules-testing/url-must-be-formatted-correctly.spec.js +++ b/docker/test/html-rules-testing/url-must-be-formatted-correctly.spec.js @@ -20,6 +20,12 @@ describe(`Rules: ${ruldId}`, () => { expect(messages.length).to.be(1); }); + it('URL with only "/" should not result in an error', () => { + const code = ''; + const messages = HTMLHint.verify(code, ruleOptions); + expect(messages.length).to.be(0); + }); + it("Correctly formatted URL with space should not result any error", () => { const code = ''; const messages = HTMLHint.verify(code, ruleOptions);