shelving 1.193.0 → 1.193.1
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/package.json +1 -1
- package/store/PathStore.js +4 -4
- package/util/path.d.ts +2 -2
- package/util/path.js +5 -5
package/package.json
CHANGED
package/store/PathStore.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isPathActive, isPathProud,
|
|
1
|
+
import { isPathActive, isPathProud, requirePath } from "../util/path.js";
|
|
2
2
|
import { BusyStore } from "./BusyStore.js";
|
|
3
3
|
/**
|
|
4
4
|
* Store an absolute path, e.g. `/a/b/c`
|
|
@@ -10,12 +10,12 @@ export class PathStore extends BusyStore {
|
|
|
10
10
|
base;
|
|
11
11
|
// Override to set default path to `.` and base to `/`
|
|
12
12
|
constructor(path = ".", base = "/") {
|
|
13
|
-
super(
|
|
13
|
+
super(requirePath(path, base, PathStore));
|
|
14
14
|
this.base = base;
|
|
15
15
|
}
|
|
16
16
|
// Override to convert a possible path to an absolute path (relative to `this.base`).
|
|
17
17
|
_convert(possible, caller) {
|
|
18
|
-
return
|
|
18
|
+
return requirePath(possible, this.base, caller);
|
|
19
19
|
}
|
|
20
20
|
// Override for fast equality.
|
|
21
21
|
_equal(a, b) {
|
|
@@ -31,7 +31,7 @@ export class PathStore extends BusyStore {
|
|
|
31
31
|
}
|
|
32
32
|
/** Get an absolute path from a path relative to the current store path. */
|
|
33
33
|
getPath(path) {
|
|
34
|
-
return
|
|
34
|
+
return requirePath(path, this.value);
|
|
35
35
|
}
|
|
36
36
|
toString() {
|
|
37
37
|
return this.value;
|
package/util/path.d.ts
CHANGED
|
@@ -44,7 +44,7 @@ export declare function joinPath(...segments: PathSegments): AbsolutePath;
|
|
|
44
44
|
* @param base Absolute path used for resolving relative paths in `possible`
|
|
45
45
|
* @return Absolute path with a leading slash but no trailing slash, e.g. `/a/c/b`
|
|
46
46
|
*/
|
|
47
|
-
export declare function
|
|
47
|
+
export declare function getPath(path: Nullish<PossiblePath>, base?: AbsolutePath): AbsolutePath | undefined;
|
|
48
48
|
/**
|
|
49
49
|
* Resolve a relative or absolute path and return the path, or throw `RequiredError` if not a valid path.
|
|
50
50
|
* - Internally uses `new URL` to do path processing but shouldn't ever reveal that fact.
|
|
@@ -54,7 +54,7 @@ export declare function getAbsolutePath(path: Nullish<PossiblePath>, base?: Abso
|
|
|
54
54
|
* @param base Absolute path used for resolving relative paths in `possible`
|
|
55
55
|
* @return Absolute path with a leading trailing slash, e.g. `/a/c/b`
|
|
56
56
|
*/
|
|
57
|
-
export declare function
|
|
57
|
+
export declare function requirePath(path: AbsolutePath | RelativePath, base?: AbsolutePath, caller?: AnyCaller): AbsolutePath;
|
|
58
58
|
/**
|
|
59
59
|
* Match and strip a base path prefix from a path using segment-aware pathname rules.
|
|
60
60
|
* - Both inputs must be absolute paths that begin with `/`.
|
package/util/path.js
CHANGED
|
@@ -48,7 +48,7 @@ export function joinPath(...segments) {
|
|
|
48
48
|
* @param base Absolute path used for resolving relative paths in `possible`
|
|
49
49
|
* @return Absolute path with a leading slash but no trailing slash, e.g. `/a/c/b`
|
|
50
50
|
*/
|
|
51
|
-
export function
|
|
51
|
+
export function getPath(path, base = "/") {
|
|
52
52
|
if (!path)
|
|
53
53
|
return;
|
|
54
54
|
if (path === "/")
|
|
@@ -66,8 +66,8 @@ export function getAbsolutePath(path, base = "/") {
|
|
|
66
66
|
* @param base Absolute path used for resolving relative paths in `possible`
|
|
67
67
|
* @return Absolute path with a leading trailing slash, e.g. `/a/c/b`
|
|
68
68
|
*/
|
|
69
|
-
export function
|
|
70
|
-
const output =
|
|
69
|
+
export function requirePath(path, base, caller = requirePath) {
|
|
70
|
+
const output = getPath(path, base);
|
|
71
71
|
if (!output)
|
|
72
72
|
throw new RequiredError("Invalid path", { received: path, caller });
|
|
73
73
|
return output;
|
|
@@ -78,8 +78,8 @@ export function requireAbsolutePath(path, base, caller = requireAbsolutePath) {
|
|
|
78
78
|
* - Returns `/` when the paths are an exact match.
|
|
79
79
|
*/
|
|
80
80
|
export function matchPathPrefix(target, base, caller = matchPathPrefix) {
|
|
81
|
-
const basePath =
|
|
82
|
-
const targetPath =
|
|
81
|
+
const basePath = requirePath(base, undefined, caller);
|
|
82
|
+
const targetPath = requirePath(target, basePath, caller);
|
|
83
83
|
if (basePath === "/")
|
|
84
84
|
return targetPath;
|
|
85
85
|
if (targetPath === basePath)
|