@vuepress/utils 2.0.0-beta.46 → 2.0.0-beta.49
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/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/isChildPath.d.ts +5 -0
- package/lib/isChildPath.js +19 -0
- package/package.json +2 -2
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -27,6 +27,7 @@ exports.fs = require("fs-extra");
|
|
|
27
27
|
exports.path = require("upath");
|
|
28
28
|
__exportStar(require("./hasExportDefault"), exports);
|
|
29
29
|
__exportStar(require("./hash"), exports);
|
|
30
|
+
__exportStar(require("./isChildPath"), exports);
|
|
30
31
|
__exportStar(require("./logger"), exports);
|
|
31
32
|
__exportStar(require("./renderHead"), exports);
|
|
32
33
|
__exportStar(require("./renderHeadAttrs"), exports);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isChildPath = void 0;
|
|
4
|
+
const path = require("upath");
|
|
5
|
+
/**
|
|
6
|
+
* Check if `child` is a sub path of `parent` or not. Return `true` if
|
|
7
|
+
* they are the same path
|
|
8
|
+
*/
|
|
9
|
+
const isChildPath = (child, parent) => {
|
|
10
|
+
const childPath = path.normalize(child);
|
|
11
|
+
const parentPath = path.normalize(parent);
|
|
12
|
+
// path.win32.isAbsolute could check both win32 and posix absolute path correctly
|
|
13
|
+
if (!path.win32.isAbsolute(childPath) || !path.win32.isAbsolute(parentPath)) {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
const relativePath = path.relative(parentPath, childPath);
|
|
17
|
+
return relativePath === '' || !relativePath.startsWith('..');
|
|
18
|
+
};
|
|
19
|
+
exports.isChildPath = isChildPath;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vuepress/utils",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.49",
|
|
4
4
|
"description": "Utils package of VuePress",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"vuepress",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@types/debug": "^4.1.7",
|
|
26
26
|
"@types/fs-extra": "^9.0.13",
|
|
27
|
-
"@vuepress/shared": "2.0.0-beta.
|
|
27
|
+
"@vuepress/shared": "2.0.0-beta.49",
|
|
28
28
|
"chalk": "^4.1.2",
|
|
29
29
|
"debug": "^4.3.4",
|
|
30
30
|
"fs-extra": "^10.1.0",
|