@apidevtools/json-schema-ref-parser 13.0.1 → 13.0.2
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/dist/lib/util/url.js +11 -8
- package/lib/util/url.ts +10 -7
- package/package.json +1 -1
package/dist/lib/util/url.js
CHANGED
|
@@ -90,17 +90,20 @@ function resolve(from, to) {
|
|
|
90
90
|
* @returns
|
|
91
91
|
*/
|
|
92
92
|
function cwd() {
|
|
93
|
-
if (typeof window !== "undefined") {
|
|
93
|
+
if (typeof window !== "undefined" && window.location) {
|
|
94
94
|
return location.href;
|
|
95
95
|
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
96
|
+
if (typeof process !== "undefined" && process.cwd) {
|
|
97
|
+
const path = process.cwd();
|
|
98
|
+
const lastChar = path.slice(-1);
|
|
99
|
+
if (lastChar === "/" || lastChar === "\\") {
|
|
100
|
+
return path;
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
return path + "/";
|
|
104
|
+
}
|
|
103
105
|
}
|
|
106
|
+
return "/";
|
|
104
107
|
}
|
|
105
108
|
/**
|
|
106
109
|
* Returns the protocol of the given URL, or `undefined` if it has no protocol.
|
package/lib/util/url.ts
CHANGED
|
@@ -44,18 +44,21 @@ export function resolve(from: string, to: string) {
|
|
|
44
44
|
* @returns
|
|
45
45
|
*/
|
|
46
46
|
export function cwd() {
|
|
47
|
-
if (typeof window !== "undefined") {
|
|
47
|
+
if (typeof window !== "undefined" && window.location) {
|
|
48
48
|
return location.href;
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
|
|
51
|
+
if (typeof process !== "undefined" && process.cwd) {
|
|
52
|
+
const path = process.cwd();
|
|
52
53
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
54
|
+
const lastChar = path.slice(-1);
|
|
55
|
+
if (lastChar === "/" || lastChar === "\\") {
|
|
56
|
+
return path;
|
|
57
|
+
} else {
|
|
58
|
+
return path + "/";
|
|
59
|
+
}
|
|
58
60
|
}
|
|
61
|
+
return "/";
|
|
59
62
|
}
|
|
60
63
|
|
|
61
64
|
/**
|