@docusaurus/utils 0.0.0-4315 → 0.0.0-4325
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/escapePath.d.ts +3 -3
- package/lib/escapePath.js +3 -3
- package/lib/posixPath.d.ts +5 -2
- package/lib/posixPath.d.ts.map +1 -1
- package/lib/posixPath.js +8 -6
- package/lib/posixPath.js.map +1 -1
- package/lib/webpackUtils.js +3 -3
- package/lib/webpackUtils.js.map +1 -1
- package/package.json +4 -4
- package/src/escapePath.ts +3 -3
- package/src/posixPath.ts +8 -6
- package/src/webpackUtils.ts +4 -4
package/lib/escapePath.d.ts
CHANGED
|
@@ -10,9 +10,9 @@
|
|
|
10
10
|
* For example, this would fail due to unescaped \: `<img src={require('${filePath}')} />`
|
|
11
11
|
* But this would work: `<img src={require('${escapePath(filePath)}')} />`
|
|
12
12
|
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
13
|
+
* posixPath can't be used in all cases, because forward slashes are only valid
|
|
14
|
+
* Windows paths when they don't contain non-ascii characters, and posixPath
|
|
15
|
+
* doesn't escape those that fail to be converted.
|
|
16
16
|
*/
|
|
17
17
|
export declare function escapePath(str: string): string;
|
|
18
18
|
//# sourceMappingURL=escapePath.d.ts.map
|
package/lib/escapePath.js
CHANGED
|
@@ -13,9 +13,9 @@ exports.escapePath = void 0;
|
|
|
13
13
|
* For example, this would fail due to unescaped \: `<img src={require('${filePath}')} />`
|
|
14
14
|
* But this would work: `<img src={require('${escapePath(filePath)}')} />`
|
|
15
15
|
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
16
|
+
* posixPath can't be used in all cases, because forward slashes are only valid
|
|
17
|
+
* Windows paths when they don't contain non-ascii characters, and posixPath
|
|
18
|
+
* doesn't escape those that fail to be converted.
|
|
19
19
|
*/
|
|
20
20
|
function escapePath(str) {
|
|
21
21
|
const escaped = JSON.stringify(str);
|
package/lib/posixPath.d.ts
CHANGED
|
@@ -6,10 +6,13 @@
|
|
|
6
6
|
*/
|
|
7
7
|
/**
|
|
8
8
|
* Convert Windows backslash paths to posix style paths.
|
|
9
|
-
* E.g: endi
|
|
9
|
+
* E.g: endi\lie -> endi/lie
|
|
10
10
|
*
|
|
11
|
-
*
|
|
11
|
+
* Returns original path if the posix counterpart is not valid Windows path.
|
|
12
|
+
* This makes the legacy code that uses posixPath safe; but also makes it less
|
|
13
|
+
* useful when you actually want a path with forward slashes (e.g. for URL)
|
|
12
14
|
*
|
|
15
|
+
* Adopted from https://github.com/sindresorhus/slash/blob/main/index.js
|
|
13
16
|
*/
|
|
14
17
|
export declare function posixPath(str: string): string;
|
|
15
18
|
//# sourceMappingURL=posixPath.d.ts.map
|
package/lib/posixPath.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"posixPath.d.ts","sourceRoot":"","sources":["../src/posixPath.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH
|
|
1
|
+
{"version":3,"file":"posixPath.d.ts","sourceRoot":"","sources":["../src/posixPath.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;;;;;;;GASG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAW7C"}
|
package/lib/posixPath.js
CHANGED
|
@@ -9,17 +9,19 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
9
9
|
exports.posixPath = void 0;
|
|
10
10
|
/**
|
|
11
11
|
* Convert Windows backslash paths to posix style paths.
|
|
12
|
-
* E.g: endi
|
|
12
|
+
* E.g: endi\lie -> endi/lie
|
|
13
13
|
*
|
|
14
|
-
*
|
|
14
|
+
* Returns original path if the posix counterpart is not valid Windows path.
|
|
15
|
+
* This makes the legacy code that uses posixPath safe; but also makes it less
|
|
16
|
+
* useful when you actually want a path with forward slashes (e.g. for URL)
|
|
15
17
|
*
|
|
18
|
+
* Adopted from https://github.com/sindresorhus/slash/blob/main/index.js
|
|
16
19
|
*/
|
|
17
20
|
function posixPath(str) {
|
|
18
21
|
const isExtendedLengthPath = /^\\\\\?\\/.test(str);
|
|
19
|
-
//
|
|
20
|
-
//
|
|
21
|
-
|
|
22
|
-
const hasNonAscii = /[^\u0000-\u0080]+/.test(str); // eslint-disable-line
|
|
22
|
+
// Forward slashes are only valid Windows paths when they don't contain non-ascii characters.
|
|
23
|
+
// eslint-disable-next-line no-control-regex
|
|
24
|
+
const hasNonAscii = /[^\u0000-\u0080]+/.test(str);
|
|
23
25
|
if (isExtendedLengthPath || hasNonAscii) {
|
|
24
26
|
return str;
|
|
25
27
|
}
|
package/lib/posixPath.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"posixPath.js","sourceRoot":"","sources":["../src/posixPath.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH
|
|
1
|
+
{"version":3,"file":"posixPath.js","sourceRoot":"","sources":["../src/posixPath.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH;;;;;;;;;GASG;AACH,SAAgB,SAAS,CAAC,GAAW;IACnC,MAAM,oBAAoB,GAAG,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAEnD,6FAA6F;IAC7F,4CAA4C;IAC5C,MAAM,WAAW,GAAG,mBAAmB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAElD,IAAI,oBAAoB,IAAI,WAAW,EAAE;QACvC,OAAO,GAAG,CAAC;KACZ;IACD,OAAO,GAAG,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;AACjC,CAAC;AAXD,8BAWC"}
|
package/lib/webpackUtils.js
CHANGED
|
@@ -9,7 +9,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
9
9
|
exports.getFileLoaderUtils = void 0;
|
|
10
10
|
const tslib_1 = require("tslib");
|
|
11
11
|
const path_1 = (0, tslib_1.__importDefault)(require("path"));
|
|
12
|
-
const
|
|
12
|
+
const escapePath_1 = require("./escapePath");
|
|
13
13
|
const constants_1 = require("./constants");
|
|
14
14
|
// Inspired by https://github.com/gatsbyjs/gatsby/blob/8e6e021014da310b9cc7d02e58c9b3efe938c665/packages/gatsby/src/utils/webpack-utils.ts#L447
|
|
15
15
|
function getFileLoaderUtils() {
|
|
@@ -37,8 +37,8 @@ function getFileLoaderUtils() {
|
|
|
37
37
|
// Maybe with the ideal image plugin, all md images should be "ideal"?
|
|
38
38
|
// This is used to force url-loader+file-loader on markdown images
|
|
39
39
|
// https://webpack.js.org/concepts/loaders/#inline
|
|
40
|
-
inlineMarkdownImageFileLoader: `!${(0,
|
|
41
|
-
inlineMarkdownLinkFileLoader: `!${(0,
|
|
40
|
+
inlineMarkdownImageFileLoader: `!${(0, escapePath_1.escapePath)(require.resolve('url-loader'))}?limit=${urlLoaderLimit}&name=${fileLoaderFileName('images')}&fallback=${(0, escapePath_1.escapePath)(require.resolve('file-loader'))}!`,
|
|
41
|
+
inlineMarkdownLinkFileLoader: `!${(0, escapePath_1.escapePath)(require.resolve('file-loader'))}?name=${fileLoaderFileName('files')}!`,
|
|
42
42
|
};
|
|
43
43
|
const rules = {
|
|
44
44
|
/**
|
package/lib/webpackUtils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webpackUtils.js","sourceRoot":"","sources":["../src/webpackUtils.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;AAGH,6DAAwB;AACxB,
|
|
1
|
+
{"version":3,"file":"webpackUtils.js","sourceRoot":"","sources":["../src/webpackUtils.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;AAGH,6DAAwB;AACxB,6CAAwC;AACxC,2CAGqB;AAoBrB,+IAA+I;AAC/I,SAAgB,kBAAkB;IAChC,uFAAuF;IACvF,MAAM,cAAc,GAAG,oCAAwB,CAAC;IAEhD,4DAA4D;IAC5D,MAAM,kBAAkB,GAAG,CAAC,MAAmB,EAAE,EAAE,CACjD,GAAG,yCAA6B,IAAI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AAC;AA7GD,gDA6GC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docusaurus/utils",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-4325",
|
|
4
4
|
"description": "Node utility functions for Docusaurus packages.",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"types": "./lib/index.d.ts",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
},
|
|
19
19
|
"license": "MIT",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@docusaurus/logger": "0.0.0-
|
|
21
|
+
"@docusaurus/logger": "0.0.0-4325",
|
|
22
22
|
"@mdx-js/runtime": "^1.6.22",
|
|
23
23
|
"@svgr/webpack": "^6.0.0",
|
|
24
24
|
"escape-string-regexp": "^4.0.0",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"node": ">=14"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"@docusaurus/types": "0.0.0-
|
|
42
|
+
"@docusaurus/types": "0.0.0-4325",
|
|
43
43
|
"@types/dedent": "^0.7.0",
|
|
44
44
|
"@types/github-slugger": "^1.3.0",
|
|
45
45
|
"@types/micromatch": "^4.0.2",
|
|
@@ -52,5 +52,5 @@
|
|
|
52
52
|
"react-dom": "*",
|
|
53
53
|
"webpack": "5.x"
|
|
54
54
|
},
|
|
55
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "faf4f3f741b442a5805d6e871788a631839a9cc9"
|
|
56
56
|
}
|
package/src/escapePath.ts
CHANGED
|
@@ -11,9 +11,9 @@
|
|
|
11
11
|
* For example, this would fail due to unescaped \: `<img src={require('${filePath}')} />`
|
|
12
12
|
* But this would work: `<img src={require('${escapePath(filePath)}')} />`
|
|
13
13
|
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
14
|
+
* posixPath can't be used in all cases, because forward slashes are only valid
|
|
15
|
+
* Windows paths when they don't contain non-ascii characters, and posixPath
|
|
16
|
+
* doesn't escape those that fail to be converted.
|
|
17
17
|
*/
|
|
18
18
|
export function escapePath(str: string): string {
|
|
19
19
|
const escaped = JSON.stringify(str);
|
package/src/posixPath.ts
CHANGED
|
@@ -7,18 +7,20 @@
|
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Convert Windows backslash paths to posix style paths.
|
|
10
|
-
* E.g: endi
|
|
10
|
+
* E.g: endi\lie -> endi/lie
|
|
11
11
|
*
|
|
12
|
-
*
|
|
12
|
+
* Returns original path if the posix counterpart is not valid Windows path.
|
|
13
|
+
* This makes the legacy code that uses posixPath safe; but also makes it less
|
|
14
|
+
* useful when you actually want a path with forward slashes (e.g. for URL)
|
|
13
15
|
*
|
|
16
|
+
* Adopted from https://github.com/sindresorhus/slash/blob/main/index.js
|
|
14
17
|
*/
|
|
15
18
|
export function posixPath(str: string): string {
|
|
16
19
|
const isExtendedLengthPath = /^\\\\\?\\/.test(str);
|
|
17
20
|
|
|
18
|
-
//
|
|
19
|
-
//
|
|
20
|
-
|
|
21
|
-
const hasNonAscii = /[^\u0000-\u0080]+/.test(str); // eslint-disable-line
|
|
21
|
+
// Forward slashes are only valid Windows paths when they don't contain non-ascii characters.
|
|
22
|
+
// eslint-disable-next-line no-control-regex
|
|
23
|
+
const hasNonAscii = /[^\u0000-\u0080]+/.test(str);
|
|
22
24
|
|
|
23
25
|
if (isExtendedLengthPath || hasNonAscii) {
|
|
24
26
|
return str;
|
package/src/webpackUtils.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
import type {RuleSetRule} from 'webpack';
|
|
9
9
|
import path from 'path';
|
|
10
|
-
import {
|
|
10
|
+
import {escapePath} from './escapePath';
|
|
11
11
|
import {
|
|
12
12
|
WEBPACK_URL_LOADER_LIMIT,
|
|
13
13
|
OUTPUT_STATIC_ASSETS_DIR_NAME,
|
|
@@ -61,12 +61,12 @@ export function getFileLoaderUtils(): FileLoaderUtils {
|
|
|
61
61
|
// Maybe with the ideal image plugin, all md images should be "ideal"?
|
|
62
62
|
// This is used to force url-loader+file-loader on markdown images
|
|
63
63
|
// https://webpack.js.org/concepts/loaders/#inline
|
|
64
|
-
inlineMarkdownImageFileLoader: `!${
|
|
64
|
+
inlineMarkdownImageFileLoader: `!${escapePath(
|
|
65
65
|
require.resolve('url-loader'),
|
|
66
66
|
)}?limit=${urlLoaderLimit}&name=${fileLoaderFileName(
|
|
67
67
|
'images',
|
|
68
|
-
)}&fallback=${
|
|
69
|
-
inlineMarkdownLinkFileLoader: `!${
|
|
68
|
+
)}&fallback=${escapePath(require.resolve('file-loader'))}!`,
|
|
69
|
+
inlineMarkdownLinkFileLoader: `!${escapePath(
|
|
70
70
|
require.resolve('file-loader'),
|
|
71
71
|
)}?name=${fileLoaderFileName('files')}!`,
|
|
72
72
|
};
|