fix(utils): handle Markdown links with spaces to route correctly (#8874)

This commit is contained in:
Aleksandr Vladykin 2023-04-12 20:14:26 +03:00 committed by GitHub
parent 3d31c55fe7
commit 2b994262b0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 40 additions and 1 deletions

View file

@ -256,6 +256,31 @@ The following operations are defined for [URI]s:
},
fileString: `
[a](a.md), [a](a.md), [b](b.md), [c](c.md)
`,
}),
).toMatchSnapshot();
});
it('replaces Markdown links with spaces', () => {
expect(
replaceMarkdownLinks({
siteDir: '.',
filePath: 'docs/intro.md',
contentPaths: {
contentPath: 'docs',
contentPathLocalized: 'i18n/docs-localized',
},
sourceToPermalink: {
'@site/docs/doc a.md': '/docs/doc%20a',
'@site/docs/my docs/doc b.md': '/docs/my%20docs/doc%20b',
},
fileString: `
[doc a](./doc%20a.md)
[doc a](<./doc a.md>)
[doc a](./doc a.md)
[doc b](./my%20docs/doc%20b.md)
[doc b](<./my docs/doc b.md>)
[doc b](./my docs/doc b.md)
`,
}),
).toMatchSnapshot();