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:
Joshua Chen 2021-12-25 15:24:21 +08:00 committed by GitHub
parent 6716548b87
commit f02fefb5b7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 38 additions and 37 deletions

View file

@ -7,7 +7,7 @@
import type {RuleSetRule} from 'webpack';
import path from 'path';
import {posixPath} from './posixPath';
import {escapePath} from './escapePath';
import {
WEBPACK_URL_LOADER_LIMIT,
OUTPUT_STATIC_ASSETS_DIR_NAME,
@ -61,12 +61,12 @@ export function getFileLoaderUtils(): FileLoaderUtils {
// Maybe with the ideal image plugin, all md images should be "ideal"?
// This is used to force url-loader+file-loader on markdown images
// https://webpack.js.org/concepts/loaders/#inline
inlineMarkdownImageFileLoader: `!${posixPath(
inlineMarkdownImageFileLoader: `!${escapePath(
require.resolve('url-loader'),
)}?limit=${urlLoaderLimit}&name=${fileLoaderFileName(
'images',
)}&fallback=${posixPath(require.resolve('file-loader'))}!`,
inlineMarkdownLinkFileLoader: `!${posixPath(
)}&fallback=${escapePath(require.resolve('file-loader'))}!`,
inlineMarkdownLinkFileLoader: `!${escapePath(
require.resolve('file-loader'),
)}?name=${fileLoaderFileName('files')}!`,
};