Skip to content

Commit

Permalink
Fixed url format custom rule to ignore root link
Browse files Browse the repository at this point in the history
  • Loading branch information
tombui99 committed Apr 30, 2024
1 parent 015ce97 commit 2756c10
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion docker/customHtmlRules.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) === "."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '<a href="/" />';
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 = '<a href="www.ssw.com.au/This is a rule" />';
const messages = HTMLHint.verify(code, ruleOptions);
Expand Down

0 comments on commit 2756c10

Please sign in to comment.