@docusaurus/utils 0.0.0-4342 → 0.0.0-4351
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/dataFileUtils.d.ts +24 -0
- package/lib/dataFileUtils.d.ts.map +1 -0
- package/lib/dataFileUtils.js +68 -0
- package/lib/dataFileUtils.js.map +1 -0
- package/lib/index.d.ts +7 -38
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +8 -128
- package/lib/index.js.map +1 -1
- package/lib/markdownLinks.js +2 -2
- package/lib/markdownLinks.js.map +1 -1
- package/lib/markdownParser.d.ts +4 -0
- package/lib/markdownParser.d.ts.map +1 -1
- package/lib/markdownParser.js +17 -1
- package/lib/markdownParser.js.map +1 -1
- package/lib/pathUtils.d.ts +29 -0
- package/lib/pathUtils.d.ts.map +1 -1
- package/lib/pathUtils.js +63 -1
- package/lib/pathUtils.js.map +1 -1
- package/lib/tags.js +2 -2
- package/lib/tags.js.map +1 -1
- package/lib/{normalizeUrl.d.ts → urlUtils.d.ts} +2 -1
- package/lib/urlUtils.d.ts.map +1 -0
- package/lib/{normalizeUrl.js → urlUtils.js} +9 -2
- package/lib/urlUtils.js.map +1 -0
- package/lib/webpackUtils.js +3 -3
- package/lib/webpackUtils.js.map +1 -1
- package/package.json +5 -5
- package/src/dataFileUtils.ts +93 -0
- package/src/index.ts +8 -154
- package/src/markdownLinks.ts +1 -1
- package/src/markdownParser.ts +18 -0
- package/src/pathUtils.ts +65 -0
- package/src/tags.ts +1 -1
- package/src/{normalizeUrl.ts → urlUtils.ts} +10 -0
- package/src/webpackUtils.ts +1 -1
- package/lib/escapePath.d.ts +0 -18
- package/lib/escapePath.d.ts.map +0 -1
- package/lib/escapePath.js +0 -26
- package/lib/escapePath.js.map +0 -1
- package/lib/normalizeUrl.d.ts.map +0 -1
- package/lib/normalizeUrl.js.map +0 -1
- package/lib/posixPath.d.ts +0 -18
- package/lib/posixPath.d.ts.map +0 -1
- package/lib/posixPath.js +0 -31
- package/lib/posixPath.js.map +0 -1
- package/src/escapePath.ts +0 -23
- package/src/posixPath.ts +0 -29
package/src/tags.ts
CHANGED
|
@@ -78,3 +78,13 @@ export function normalizeUrl(rawUrls: string[]): string {
|
|
|
78
78
|
|
|
79
79
|
return str;
|
|
80
80
|
}
|
|
81
|
+
|
|
82
|
+
export function getEditUrl(
|
|
83
|
+
fileRelativePath: string,
|
|
84
|
+
editUrl?: string,
|
|
85
|
+
): string | undefined {
|
|
86
|
+
return editUrl
|
|
87
|
+
? // Don't use posixPath for this: we need to force a forward slash path
|
|
88
|
+
normalizeUrl([editUrl, fileRelativePath.replace(/\\/g, '/')])
|
|
89
|
+
: undefined;
|
|
90
|
+
}
|
package/src/webpackUtils.ts
CHANGED
package/lib/escapePath.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/
|
|
7
|
-
/**
|
|
8
|
-
* When you have a path like C:\X\Y
|
|
9
|
-
* It is not safe to use directly when generating code
|
|
10
|
-
* For example, this would fail due to unescaped \: `<img src={require('${filePath}')} />`
|
|
11
|
-
* But this would work: `<img src={require('${escapePath(filePath)}')} />`
|
|
12
|
-
*
|
|
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
|
-
*/
|
|
17
|
-
export declare function escapePath(str: string): string;
|
|
18
|
-
//# sourceMappingURL=escapePath.d.ts.map
|
package/lib/escapePath.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"escapePath.d.ts","sourceRoot":"","sources":["../src/escapePath.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;;;;;;;GASG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAK9C"}
|
package/lib/escapePath.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
4
|
-
*
|
|
5
|
-
* This source code is licensed under the MIT license found in the
|
|
6
|
-
* LICENSE file in the root directory of this source tree.
|
|
7
|
-
*/
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.escapePath = void 0;
|
|
10
|
-
/**
|
|
11
|
-
* When you have a path like C:\X\Y
|
|
12
|
-
* It is not safe to use directly when generating code
|
|
13
|
-
* For example, this would fail due to unescaped \: `<img src={require('${filePath}')} />`
|
|
14
|
-
* But this would work: `<img src={require('${escapePath(filePath)}')} />`
|
|
15
|
-
*
|
|
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
|
-
*/
|
|
20
|
-
function escapePath(str) {
|
|
21
|
-
const escaped = JSON.stringify(str);
|
|
22
|
-
// Remove the " around the json string;
|
|
23
|
-
return escaped.substring(1, escaped.length - 1);
|
|
24
|
-
}
|
|
25
|
-
exports.escapePath = escapePath;
|
|
26
|
-
//# sourceMappingURL=escapePath.js.map
|
package/lib/escapePath.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"escapePath.js","sourceRoot":"","sources":["../src/escapePath.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH;;;;;;;;;GASG;AACH,SAAgB,UAAU,CAAC,GAAW;IACpC,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;IAEpC,uCAAuC;IACvC,OAAO,OAAO,CAAC,SAAS,CAAC,CAAC,EAAE,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;AAClD,CAAC;AALD,gCAKC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"normalizeUrl.d.ts","sourceRoot":"","sources":["../src/normalizeUrl.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,MAAM,CAwEtD"}
|
package/lib/normalizeUrl.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"normalizeUrl.js","sourceRoot":"","sources":["../src/normalizeUrl.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,SAAgB,YAAY,CAAC,OAAiB;IAC5C,MAAM,IAAI,GAAG,CAAC,GAAG,OAAO,CAAC,CAAC;IAC1B,MAAM,WAAW,GAAG,EAAE,CAAC;IAEvB,IAAI,gBAAgB,GAAG,KAAK,CAAC;IAC7B,IAAI,cAAc,GAAG,KAAK,CAAC;IAE3B,2EAA2E;IAC3E,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,cAAc,CAAC,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE;QACpD,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,EAAE,CAAC;QAC3B,IAAI,CAAC,CAAC,CAAC,GAAG,KAAK,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;KAC3B;IAED,2DAA2D;IAC3D,gCAAgC;IAChC,MAAM,WAAW,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC;IACvE,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,eAAe,EAAE,WAAW,CAAC,CAAC;IAExD,2BAA2B;IAC3B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC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AAM,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC7B,GAAG,GAAG,KAAK,CAAC,KAAK,EAAE,GAAG,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAEtE,wEAAwE;IACxE,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC,cAAc,EAAE,IAAI,CAAC,CAAC;IAExC,uDAAuD;IACvD,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;IAEhC,OAAO,GAAG,CAAC;AACb,CAAC;AAxED,oCAwEC"}
|
package/lib/posixPath.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/
|
|
7
|
-
/**
|
|
8
|
-
* Convert Windows backslash paths to posix style paths.
|
|
9
|
-
* E.g: endi\lie -> endi/lie
|
|
10
|
-
*
|
|
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)
|
|
14
|
-
*
|
|
15
|
-
* Adopted from https://github.com/sindresorhus/slash/blob/main/index.js
|
|
16
|
-
*/
|
|
17
|
-
export declare function posixPath(str: string): string;
|
|
18
|
-
//# sourceMappingURL=posixPath.d.ts.map
|
package/lib/posixPath.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
4
|
-
*
|
|
5
|
-
* This source code is licensed under the MIT license found in the
|
|
6
|
-
* LICENSE file in the root directory of this source tree.
|
|
7
|
-
*/
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.posixPath = void 0;
|
|
10
|
-
/**
|
|
11
|
-
* Convert Windows backslash paths to posix style paths.
|
|
12
|
-
* E.g: endi\lie -> endi/lie
|
|
13
|
-
*
|
|
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)
|
|
17
|
-
*
|
|
18
|
-
* Adopted from https://github.com/sindresorhus/slash/blob/main/index.js
|
|
19
|
-
*/
|
|
20
|
-
function posixPath(str) {
|
|
21
|
-
const isExtendedLengthPath = /^\\\\\?\\/.test(str);
|
|
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);
|
|
25
|
-
if (isExtendedLengthPath || hasNonAscii) {
|
|
26
|
-
return str;
|
|
27
|
-
}
|
|
28
|
-
return str.replace(/\\/g, '/');
|
|
29
|
-
}
|
|
30
|
-
exports.posixPath = posixPath;
|
|
31
|
-
//# sourceMappingURL=posixPath.js.map
|
package/lib/posixPath.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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/src/escapePath.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* When you have a path like C:\X\Y
|
|
10
|
-
* It is not safe to use directly when generating code
|
|
11
|
-
* For example, this would fail due to unescaped \: `<img src={require('${filePath}')} />`
|
|
12
|
-
* But this would work: `<img src={require('${escapePath(filePath)}')} />`
|
|
13
|
-
*
|
|
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
|
-
*/
|
|
18
|
-
export function escapePath(str: string): string {
|
|
19
|
-
const escaped = JSON.stringify(str);
|
|
20
|
-
|
|
21
|
-
// Remove the " around the json string;
|
|
22
|
-
return escaped.substring(1, escaped.length - 1);
|
|
23
|
-
}
|
package/src/posixPath.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Convert Windows backslash paths to posix style paths.
|
|
10
|
-
* E.g: endi\lie -> endi/lie
|
|
11
|
-
*
|
|
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)
|
|
15
|
-
*
|
|
16
|
-
* Adopted from https://github.com/sindresorhus/slash/blob/main/index.js
|
|
17
|
-
*/
|
|
18
|
-
export function posixPath(str: string): string {
|
|
19
|
-
const isExtendedLengthPath = /^\\\\\?\\/.test(str);
|
|
20
|
-
|
|
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);
|
|
24
|
-
|
|
25
|
-
if (isExtendedLengthPath || hasNonAscii) {
|
|
26
|
-
return str;
|
|
27
|
-
}
|
|
28
|
-
return str.replace(/\\/g, '/');
|
|
29
|
-
}
|