mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-14 00:32:47 +02:00
fix(utils): properly escape Windows paths (#6190)
* fix(utils): properly escape Windows paths * Use in more places * Escape path in test * Fix snapshot * Better comment * Fix tests
This commit is contained in:
parent
6716548b87
commit
f02fefb5b7
8 changed files with 38 additions and 37 deletions
|
@ -11,7 +11,6 @@ import mdx from 'remark-mdx';
|
|||
import vfile from 'to-vfile';
|
||||
import plugin from '../index';
|
||||
import headings from '../../headings/index';
|
||||
import {posixPath} from '@docusaurus/utils';
|
||||
|
||||
const processFixture = async (name, options) => {
|
||||
const filePath = path.join(__dirname, `__fixtures__/${name}.md`);
|
||||
|
@ -24,7 +23,8 @@ const processFixture = async (name, options) => {
|
|||
|
||||
return result
|
||||
.toString()
|
||||
.replace(new RegExp(posixPath(process.cwd()), 'g'), '[CWD]');
|
||||
.replace(/\\\\/g, '/')
|
||||
.replace(new RegExp(process.cwd().replace(/\\/g, '/'), 'g'), '[CWD]');
|
||||
};
|
||||
|
||||
const staticDirs = [
|
||||
|
|
|
@ -11,7 +11,6 @@ import mdx from 'remark-mdx';
|
|||
import vfile from 'to-vfile';
|
||||
import plugin from '..';
|
||||
import transformImage from '../../transformImage';
|
||||
import {posixPath} from '@docusaurus/utils';
|
||||
|
||||
const processFixture = async (name: string, options?) => {
|
||||
const filePath = path.join(__dirname, `__fixtures__/${name}.md`);
|
||||
|
@ -33,7 +32,8 @@ const processFixture = async (name: string, options?) => {
|
|||
|
||||
return result
|
||||
.toString()
|
||||
.replace(new RegExp(posixPath(process.cwd()), 'g'), '[CWD]');
|
||||
.replace(/\\\\/g, '/')
|
||||
.replace(new RegExp(process.cwd().replace(/\\/g, '/'), 'g'), '[CWD]');
|
||||
};
|
||||
|
||||
describe('transformAsset plugin', () => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue