Skip to content

Commit 094a59d

Browse files
authored
fix: case-insensitive attribute checks in no-missing-link-fragment (#465)
fix: case-insensitive checks for HTML attributes in `no-missing-link-fragment`
1 parent 56eb0ee commit 094a59d

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

src/rules/no-missing-link-fragments.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import GithubSlugger from "github-slugger";
2828
const githubLineReferencePattern = /^L\d+(?:C\d+)?(?:-L\d+(?:C\d+)?)?$/u;
2929
const customHeadingIdPattern = /\{#([^}\s]+)\}\s*$/u;
3030
const htmlCommentPattern = /<!--[\s\S]*?-->/gu;
31-
const htmlIdNamePattern = /<(?:[^>]+)\s+(?:id|name)=["']([^"']+)["']/gu;
31+
const htmlIdNamePattern = /<(?:[^>]+)\s+(?:id|name)=["']([^"']+)["']/giu;
3232

3333
/**
3434
* Checks if the fragment is a valid GitHub line reference

tests/rules/no-missing-link-fragments.test.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,36 @@ ruleTester.run("no-missing-link-fragments", rule, {
4343
[Link](#bookmark)
4444
`,
4545

46+
// HTML anchor tags case-insensitive
47+
dedent`
48+
<a ID="bookmark"></a>
49+
[Link](#bookmark)
50+
`,
51+
52+
// HTML anchor tags case-insensitive
53+
dedent`
54+
<a Id="bookmark"></a>
55+
[Link](#bookmark)
56+
`,
57+
4658
// HTML name attribute
4759
dedent`
4860
<a name="old-style"></a>
4961
[Link](#old-style)
5062
`,
5163

64+
// HTML name attribute case-insensitive
65+
dedent`
66+
<a NAME="old-style"></a>
67+
[Link](#old-style)
68+
`,
69+
70+
// HTML name attribute case-insensitive
71+
dedent`
72+
<a NaMe="old-style"></a>
73+
[Link](#old-style)
74+
`,
75+
5276
dedent`
5377
<h1 id="bookmark">Bookmark</h1>
5478
<h1 name="old-style">Old Style</h1>

0 commit comments

Comments
 (0)