mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-16 01:32:37 +02:00
Don't replace static assets linking in fenced code blocks (#864)
* Don't replace any relative links to static assets in a fenced code block * revert unintended docs change * improve regex * remove test file :sob * stronger regex test for replace assets * super simplify solution
This commit is contained in:
parent
53993f1ba6
commit
d42ecb943f
5 changed files with 148 additions and 11 deletions
lib/server/__tests__
|
@ -49,9 +49,10 @@ const doc2 = fs.readFileSync(
|
|||
'utf8'
|
||||
);
|
||||
|
||||
const rawContent1 = metadataUtils.extractMetadata(doc1).rawContent;
|
||||
const rawContent2 = metadataUtils.extractMetadata(doc2).rawContent;
|
||||
|
||||
describe('mdToHtmlify', () => {
|
||||
const rawContent1 = metadataUtils.extractMetadata(doc1).rawContent;
|
||||
const rawContent2 = metadataUtils.extractMetadata(doc2).rawContent;
|
||||
const mdToHtml = metadataUtils.mdToHtml(Metadata, '/');
|
||||
|
||||
test('transform nothing', () => {
|
||||
|
@ -129,6 +130,31 @@ describe('getFile', () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe('replaceAssetsLink', () => {
|
||||
test('transform document with valid assets link', () => {
|
||||
const content1 = docs.replaceAssetsLink(rawContent1);
|
||||
expect(content1).toMatchSnapshot();
|
||||
expect(content1).toContain('');
|
||||
expect(content1).toContain('');
|
||||
expect(content1).toContain('');
|
||||
expect(content1).toContain('');
|
||||
expect(content1).not.toContain('');
|
||||
expect(content1).not.toContain('');
|
||||
expect(content1).not.toContain('');
|
||||
expect(content1).not.toContain('');
|
||||
expect(content1).not.toEqual(rawContent1);
|
||||
});
|
||||
|
||||
test('does not transform document without valid assets link', () => {
|
||||
const content2 = docs.replaceAssetsLink(rawContent2);
|
||||
expect(content2).toMatchSnapshot();
|
||||
expect(content2).not.toContain('');
|
||||
expect(content2).not.toContain('');
|
||||
expect(content2).not.toContain('');
|
||||
expect(content2).toEqual(rawContent2);
|
||||
});
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
process.chdir(originalCwd);
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue