mirror of
https://github.com/theoludwig/markdownlint-rule-relative-links.git
synced 2024-12-08 00:45:32 +01:00
fix: link fragment with accents should be valid if the heading exists
Fixes a regression introduced in v2.3.0, which needed to lower case/manage case insensitive heading.
This commit is contained in:
parent
f332c833ca
commit
5af131b840
@ -26,7 +26,7 @@ const convertHeadingToHTMLFragment = (inlineText) => {
|
||||
"",
|
||||
)
|
||||
.replace(/ /gu, "-"),
|
||||
)
|
||||
).toLowerCase()
|
||||
)
|
||||
}
|
||||
|
||||
|
3
test/fixtures/valid/existing-heading-with-accents/awesome.md
vendored
Normal file
3
test/fixtures/valid/existing-heading-with-accents/awesome.md
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
# Awesome
|
||||
|
||||
## Développement
|
3
test/fixtures/valid/existing-heading-with-accents/existing-heading-with-accents.md
vendored
Normal file
3
test/fixtures/valid/existing-heading-with-accents/existing-heading-with-accents.md
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
# Valid
|
||||
|
||||
[Link fragment](./awesome.md#développement)
|
@ -26,80 +26,80 @@ test("ensure the rule validates correctly", async (t) => {
|
||||
await t.test("should be invalid", async (t) => {
|
||||
const testCases = [
|
||||
{
|
||||
name: "with an empty id fragment",
|
||||
name: "should be invalid with an empty id fragment",
|
||||
fixturePath:
|
||||
"test/fixtures/invalid/empty-id-fragment/empty-id-fragment.md",
|
||||
error: '"./awesome.md#" should have a valid fragment identifier',
|
||||
},
|
||||
{
|
||||
name: "with a name fragment other than for an anchor",
|
||||
name: "should be invalid with a name fragment other than for an anchor",
|
||||
fixturePath:
|
||||
"test/fixtures/invalid/ignore-name-fragment-if-not-an-anchor/ignore-name-fragment-if-not-an-anchor.md",
|
||||
error:
|
||||
'"./awesome.md#name-should-be-ignored" should have a valid fragment identifier',
|
||||
},
|
||||
{
|
||||
name: "with a non-existing id fragment (data-id !== id)",
|
||||
name: "should be invalid with a non-existing id fragment (data-id !== id)",
|
||||
fixturePath:
|
||||
"test/fixtures/invalid/ignore-not-an-id-fragment/ignore-not-an-id-fragment.md",
|
||||
error:
|
||||
'"./awesome.md#not-an-id-should-be-ignored" should have a valid fragment identifier',
|
||||
},
|
||||
{
|
||||
name: "with invalid heading with #L fragment",
|
||||
name: "should be invalid with invalid heading with #L fragment",
|
||||
fixturePath:
|
||||
"test/fixtures/invalid/invalid-heading-with-L-fragment/invalid-heading-with-L-fragment.md",
|
||||
error: '"./awesome.md#L7abc" should have a valid fragment identifier',
|
||||
},
|
||||
{
|
||||
name: "with a invalid line number fragment",
|
||||
name: "should be invalid with a invalid line number fragment",
|
||||
fixturePath:
|
||||
"test/fixtures/invalid/invalid-line-number-fragment/invalid-line-number-fragment.md",
|
||||
error:
|
||||
'"./awesome.md#L7" should have a valid fragment identifier, "./awesome.md#L7" should have at least 7 lines to be valid',
|
||||
},
|
||||
{
|
||||
name: "with a non-existing anchor name fragment",
|
||||
name: "should be invalid with a non-existing anchor name fragment",
|
||||
fixturePath:
|
||||
"test/fixtures/invalid/non-existing-anchor-name-fragment/non-existing-anchor-name-fragment.md",
|
||||
error:
|
||||
'"./awesome.md#non-existing-anchor-name-fragment" should have a valid fragment identifier',
|
||||
},
|
||||
{
|
||||
name: "with a non-existing element id fragment",
|
||||
name: "should be invalid with a non-existing element id fragment",
|
||||
fixturePath:
|
||||
"test/fixtures/invalid/non-existing-element-id-fragment/non-existing-element-id-fragment.md",
|
||||
error:
|
||||
'"./awesome.md#non-existing-element-id-fragment" should have a valid fragment identifier',
|
||||
},
|
||||
{
|
||||
name: "with a non-existing heading fragment",
|
||||
name: "should be invalid with a non-existing heading fragment",
|
||||
fixturePath:
|
||||
"test/fixtures/invalid/non-existing-heading-fragment/non-existing-heading-fragment.md",
|
||||
error:
|
||||
'"./awesome.md#non-existing-heading" should have a valid fragment identifier',
|
||||
},
|
||||
{
|
||||
name: "with a link to an image with a empty fragment",
|
||||
name: "should be invalid with a link to an image with a empty fragment",
|
||||
fixturePath:
|
||||
"test/fixtures/invalid/ignore-empty-fragment-checking-for-image.md",
|
||||
error:
|
||||
'"../image.png#" should not have a fragment identifier as it is an image',
|
||||
},
|
||||
{
|
||||
name: "with a link to an image with a fragment",
|
||||
name: "should be invalid with a link to an image with a fragment",
|
||||
fixturePath:
|
||||
"test/fixtures/invalid/ignore-fragment-checking-for-image.md",
|
||||
error:
|
||||
'"../image.png#non-existing-fragment" should not have a fragment identifier as it is an image',
|
||||
},
|
||||
{
|
||||
name: "with a non-existing file",
|
||||
name: "should be invalid with a non-existing file",
|
||||
fixturePath: "test/fixtures/invalid/non-existing-file.md",
|
||||
error: '"./index.test.js" should exist in the file system',
|
||||
},
|
||||
{
|
||||
name: "with a non-existing image",
|
||||
name: "should be invalid with a non-existing image",
|
||||
fixturePath: "test/fixtures/invalid/non-existing-image.md",
|
||||
error: '"./image.png" should exist in the file system',
|
||||
},
|
||||
@ -122,46 +122,51 @@ test("ensure the rule validates correctly", async (t) => {
|
||||
await t.test("should be valid", async (t) => {
|
||||
const testCases = [
|
||||
{
|
||||
name: "with an existing anchor name fragment",
|
||||
name: "should be valid with an existing anchor name fragment",
|
||||
fixturePath:
|
||||
"test/fixtures/valid/existing-anchor-name-fragment/existing-anchor-name-fragment.md",
|
||||
},
|
||||
{
|
||||
name: "with an existing element id fragment",
|
||||
name: "should be valid with an existing element id fragment",
|
||||
fixturePath:
|
||||
"test/fixtures/valid/existing-element-id-fragment/existing-element-id-fragment.md",
|
||||
},
|
||||
{
|
||||
name: "with an existing heading fragment (case insensitive)",
|
||||
name: "should be valid with an existing heading fragment (case insensitive)",
|
||||
fixturePath:
|
||||
"test/fixtures/valid/existing-heading-case-insensitive/existing-heading-case-insensitive.md",
|
||||
},
|
||||
{
|
||||
name: "with an existing heading fragment",
|
||||
name: "should be valid with an existing heading fragment",
|
||||
fixturePath:
|
||||
"test/fixtures/valid/existing-heading-fragment/existing-heading-fragment.md",
|
||||
},
|
||||
{
|
||||
name: 'should be valid with an existing heading fragment with accents (e.g: "é")',
|
||||
fixturePath:
|
||||
"test/fixtures/valid/existing-heading-with-accents/existing-heading-with-accents.md",
|
||||
},
|
||||
{
|
||||
name: "should only parse markdown files for fragments checking",
|
||||
fixturePath:
|
||||
"test/fixtures/valid/only-parse-markdown-files-for-fragments/only-parse-markdown-files-for-fragments.md",
|
||||
},
|
||||
{
|
||||
name: 'with valid heading "like" line number fragment',
|
||||
name: 'should be valid with valid heading "like" line number fragment',
|
||||
fixturePath:
|
||||
"test/fixtures/valid/valid-heading-like-number-fragment/valid-heading-like-number-fragment.md",
|
||||
},
|
||||
{
|
||||
name: "with valid line number fragment",
|
||||
name: "should be valid with valid line number fragment",
|
||||
fixturePath:
|
||||
"test/fixtures/valid/valid-line-number-fragment/valid-line-number-fragment.md",
|
||||
},
|
||||
{
|
||||
name: "with an existing file",
|
||||
name: "should be valid with an existing file",
|
||||
fixturePath: "test/fixtures/valid/existing-file.md",
|
||||
},
|
||||
{
|
||||
name: "with an existing image",
|
||||
name: "should be valid with an existing image",
|
||||
fixturePath: "test/fixtures/valid/existing-image.md",
|
||||
},
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user