@apidevtools/json-schema-ref-parser 11.3.0 → 11.4.0
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/README.md +7 -2
- package/dist/lib/index.d.ts +9 -3
- package/dist/lib/index.js +1 -1
- package/dist/lib/normalize-args.js +4 -0
- package/dist/lib/options.d.ts +6 -0
- package/dist/lib/options.js +1 -0
- package/dist/lib/parse.js +8 -2
- package/dist/lib/pointer.d.ts +1 -1
- package/dist/lib/pointer.js +7 -7
- package/dist/lib/types/index.d.ts +4 -0
- package/dist/lib/util/url.d.ts +3 -3
- package/dist/lib/util/url.js +11 -4
- package/lib/index.ts +9 -29
- package/lib/normalize-args.ts +5 -0
- package/lib/options.ts +9 -0
- package/lib/parse.ts +8 -3
- package/lib/pointer.ts +8 -8
- package/lib/types/index.ts +5 -0
- package/lib/util/url.ts +14 -7
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -75,8 +75,13 @@ Example
|
|
|
75
75
|
import $RefParser from "@apidevtools/json-schema-ref-parser";
|
|
76
76
|
|
|
77
77
|
try {
|
|
78
|
-
|
|
79
|
-
|
|
78
|
+
await $RefParser.dereference(mySchema);
|
|
79
|
+
// note - by default, mySchema is modified in place, and the returned value is a reference to the same object
|
|
80
|
+
console.log(mySchema.definitions.person.properties.firstName);
|
|
81
|
+
|
|
82
|
+
// if you want to avoid modifying the original schema, you can disable the `mutateInputSchema` option
|
|
83
|
+
let clonedSchema = await $RefParser.dereference(mySchema, { mutateInputSchema: false });
|
|
84
|
+
console.log(clonedSchema.definitions.person.properties.firstName);
|
|
80
85
|
} catch (err) {
|
|
81
86
|
console.error(err);
|
|
82
87
|
}
|
package/dist/lib/index.d.ts
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
import $Refs from "./refs.js";
|
|
2
2
|
import { JSONParserError, InvalidPointerError, MissingPointerError, ResolverError, ParserError, UnmatchedParserError, UnmatchedResolverError } from "./util/errors.js";
|
|
3
3
|
import type { ParserOptions } from "./options.js";
|
|
4
|
-
import type {
|
|
5
|
-
export {
|
|
6
|
-
export
|
|
4
|
+
import type { $RefsCallback, JSONSchema, SchemaCallback } from "./types/index.js";
|
|
5
|
+
export { JSONParserError };
|
|
6
|
+
export { InvalidPointerError };
|
|
7
|
+
export { MissingPointerError };
|
|
8
|
+
export { ResolverError };
|
|
9
|
+
export { ParserError };
|
|
10
|
+
export { UnmatchedParserError };
|
|
11
|
+
export { UnmatchedResolverError };
|
|
12
|
+
type RefParserSchema = string | JSONSchema;
|
|
7
13
|
/**
|
|
8
14
|
* This class parses a JSON schema, builds a map of its JSON references and their resolved values,
|
|
9
15
|
* and provides methods for traversing, manipulating, and dereferencing those references.
|
package/dist/lib/index.js
CHANGED
|
@@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.dereference = exports.bundle = exports.resolve = exports.parse = exports.$RefParser = exports.
|
|
29
|
+
exports.dereference = exports.bundle = exports.resolve = exports.parse = exports.$RefParser = exports.UnmatchedResolverError = exports.UnmatchedParserError = exports.ParserError = exports.ResolverError = exports.MissingPointerError = exports.InvalidPointerError = exports.JSONParserError = void 0;
|
|
30
30
|
const refs_js_1 = __importDefault(require("./refs.js"));
|
|
31
31
|
const parse_js_1 = __importDefault(require("./parse.js"));
|
|
32
32
|
const normalize_args_js_1 = __importDefault(require("./normalize-args.js"));
|
|
@@ -38,6 +38,10 @@ function normalizeArgs(_args) {
|
|
|
38
38
|
catch (e) {
|
|
39
39
|
console.log(e);
|
|
40
40
|
}
|
|
41
|
+
if (!options.mutateInputSchema) {
|
|
42
|
+
// Make a deep clone of the schema, so that we don't alter the original object
|
|
43
|
+
schema = JSON.parse(JSON.stringify(schema));
|
|
44
|
+
}
|
|
41
45
|
return {
|
|
42
46
|
path,
|
|
43
47
|
schema,
|
package/dist/lib/options.d.ts
CHANGED
|
@@ -77,6 +77,12 @@ interface $RefParserOptions {
|
|
|
77
77
|
* Default: `relative`
|
|
78
78
|
*/
|
|
79
79
|
externalReferenceResolution?: "relative" | "root";
|
|
80
|
+
/**
|
|
81
|
+
* Whether to clone the schema before dereferencing it.
|
|
82
|
+
* This is useful when you want to dereference the same schema multiple times, but you don't want to modify the original schema.
|
|
83
|
+
* Default: `true` due to mutating the input being the default behavior historically
|
|
84
|
+
*/
|
|
85
|
+
mutateInputSchema?: boolean;
|
|
80
86
|
};
|
|
81
87
|
}
|
|
82
88
|
export declare const getNewOptions: (options: DeepPartial<$RefParserOptions>) => $RefParserOptions;
|
package/dist/lib/options.js
CHANGED
package/dist/lib/parse.js
CHANGED
|
@@ -33,13 +33,20 @@ exports.default = parse;
|
|
|
33
33
|
*/
|
|
34
34
|
async function parse(path, $refs, options) {
|
|
35
35
|
// Remove the URL fragment, if any
|
|
36
|
-
|
|
36
|
+
const hashIndex = path.indexOf("#");
|
|
37
|
+
let hash = "";
|
|
38
|
+
if (hashIndex >= 0) {
|
|
39
|
+
hash = path.substring(hashIndex);
|
|
40
|
+
// Remove the URL fragment, if any
|
|
41
|
+
path = path.substring(0, hashIndex);
|
|
42
|
+
}
|
|
37
43
|
// Add a new $Ref for this file, even though we don't have the value yet.
|
|
38
44
|
// This ensures that we don't simultaneously read & parse the same file multiple times
|
|
39
45
|
const $ref = $refs._add(path);
|
|
40
46
|
// This "file object" will be passed to all resolvers and parsers.
|
|
41
47
|
const file = {
|
|
42
48
|
url: path,
|
|
49
|
+
hash,
|
|
43
50
|
extension: url.getExtension(path),
|
|
44
51
|
};
|
|
45
52
|
// Read the file and then parse the data
|
|
@@ -111,7 +118,6 @@ async function readFile(file, options, $refs) {
|
|
|
111
118
|
* The promise resolves with the parsed file contents and the parser that was used.
|
|
112
119
|
*/
|
|
113
120
|
async function parseFile(file, options, $refs) {
|
|
114
|
-
// console.log('Parsing %s', file.url);
|
|
115
121
|
// Find the parsers that can read this file type.
|
|
116
122
|
// If none of the parsers are an exact match for this file, then we'll try ALL of them.
|
|
117
123
|
// This handles situations where the file IS a supported type, just with an unknown extension.
|
package/dist/lib/pointer.d.ts
CHANGED
|
@@ -74,7 +74,7 @@ declare class Pointer {
|
|
|
74
74
|
* @param [originalPath]
|
|
75
75
|
* @returns
|
|
76
76
|
*/
|
|
77
|
-
static parse(path: string, originalPath?: string):
|
|
77
|
+
static parse(path: string, originalPath?: string): string[];
|
|
78
78
|
/**
|
|
79
79
|
* Creates a JSON pointer path, by joining one or more tokens to a base path.
|
|
80
80
|
*
|
package/dist/lib/pointer.js
CHANGED
|
@@ -165,22 +165,22 @@ class Pointer {
|
|
|
165
165
|
*/
|
|
166
166
|
static parse(path, originalPath) {
|
|
167
167
|
// Get the JSON pointer from the path's hash
|
|
168
|
-
|
|
168
|
+
const pointer = url.getHash(path).substring(1);
|
|
169
169
|
// If there's no pointer, then there are no tokens,
|
|
170
170
|
// so return an empty array
|
|
171
171
|
if (!pointer) {
|
|
172
172
|
return [];
|
|
173
173
|
}
|
|
174
174
|
// Split into an array
|
|
175
|
-
|
|
175
|
+
const split = pointer.split("/");
|
|
176
176
|
// Decode each part, according to RFC 6901
|
|
177
|
-
for (let i = 0; i <
|
|
178
|
-
|
|
177
|
+
for (let i = 0; i < split.length; i++) {
|
|
178
|
+
split[i] = safeDecodeURIComponent(split[i].replace(escapedSlash, "/").replace(escapedTilde, "~"));
|
|
179
179
|
}
|
|
180
|
-
if (
|
|
181
|
-
throw new errors_js_1.InvalidPointerError(
|
|
180
|
+
if (split[0] !== "") {
|
|
181
|
+
throw new errors_js_1.InvalidPointerError(split, originalPath === undefined ? path : originalPath);
|
|
182
182
|
}
|
|
183
|
-
return
|
|
183
|
+
return split.slice(1);
|
|
184
184
|
}
|
|
185
185
|
/**
|
|
186
186
|
* Creates a JSON pointer path, by joining one or more tokens to a base path.
|
|
@@ -99,6 +99,10 @@ export interface FileInfo {
|
|
|
99
99
|
* The full URL of the file. This could be any type of URL, including "http://", "https://", "file://", "ftp://", "mongodb://", or even a local filesystem path (when running in Node.js).
|
|
100
100
|
*/
|
|
101
101
|
url: string;
|
|
102
|
+
/**
|
|
103
|
+
* The hash (URL fragment) of the file URL, including the # symbol. If the URL doesn't have a hash, then this will be an empty string.
|
|
104
|
+
*/
|
|
105
|
+
hash: string;
|
|
102
106
|
/**
|
|
103
107
|
* The lowercase file extension, such as ".json", ".yaml", ".txt", etc.
|
|
104
108
|
*/
|
package/dist/lib/util/url.d.ts
CHANGED
|
@@ -40,21 +40,21 @@ export declare function stripQuery(path: any): any;
|
|
|
40
40
|
* @param path
|
|
41
41
|
* @returns
|
|
42
42
|
*/
|
|
43
|
-
export declare function getHash(path:
|
|
43
|
+
export declare function getHash(path: undefined | string): string;
|
|
44
44
|
/**
|
|
45
45
|
* Removes the hash (URL fragment), if any, from the given path.
|
|
46
46
|
*
|
|
47
47
|
* @param path
|
|
48
48
|
* @returns
|
|
49
49
|
*/
|
|
50
|
-
export declare function stripHash(path
|
|
50
|
+
export declare function stripHash(path?: string | undefined): string;
|
|
51
51
|
/**
|
|
52
52
|
* Determines whether the given path is an HTTP(S) URL.
|
|
53
53
|
*
|
|
54
54
|
* @param path
|
|
55
55
|
* @returns
|
|
56
56
|
*/
|
|
57
|
-
export declare function isHttp(path:
|
|
57
|
+
export declare function isHttp(path: string): boolean;
|
|
58
58
|
/**
|
|
59
59
|
* Determines whether the given path is a filesystem path.
|
|
60
60
|
* This includes "file://" URLs.
|
package/dist/lib/util/url.js
CHANGED
|
@@ -52,12 +52,13 @@ exports.parse = parse;
|
|
|
52
52
|
function resolve(from, to) {
|
|
53
53
|
const fromUrl = new URL((0, convert_path_to_posix_1.default)(from), "resolve://");
|
|
54
54
|
const resolvedUrl = new URL((0, convert_path_to_posix_1.default)(to), fromUrl);
|
|
55
|
+
const endSpaces = to.match(/(\s*)$/)?.[1] || "";
|
|
55
56
|
if (resolvedUrl.protocol === "resolve:") {
|
|
56
57
|
// `from` is a relative URL.
|
|
57
58
|
const { pathname, search, hash } = resolvedUrl;
|
|
58
|
-
return pathname + search + hash;
|
|
59
|
+
return pathname + search + hash + endSpaces;
|
|
59
60
|
}
|
|
60
|
-
return resolvedUrl.toString();
|
|
61
|
+
return resolvedUrl.toString() + endSpaces;
|
|
61
62
|
}
|
|
62
63
|
exports.resolve = resolve;
|
|
63
64
|
/**
|
|
@@ -129,9 +130,12 @@ exports.stripQuery = stripQuery;
|
|
|
129
130
|
* @returns
|
|
130
131
|
*/
|
|
131
132
|
function getHash(path) {
|
|
133
|
+
if (!path) {
|
|
134
|
+
return "#";
|
|
135
|
+
}
|
|
132
136
|
const hashIndex = path.indexOf("#");
|
|
133
137
|
if (hashIndex >= 0) {
|
|
134
|
-
return path.
|
|
138
|
+
return path.substring(hashIndex);
|
|
135
139
|
}
|
|
136
140
|
return "#";
|
|
137
141
|
}
|
|
@@ -143,9 +147,12 @@ exports.getHash = getHash;
|
|
|
143
147
|
* @returns
|
|
144
148
|
*/
|
|
145
149
|
function stripHash(path) {
|
|
150
|
+
if (!path) {
|
|
151
|
+
return "";
|
|
152
|
+
}
|
|
146
153
|
const hashIndex = path.indexOf("#");
|
|
147
154
|
if (hashIndex >= 0) {
|
|
148
|
-
path = path.
|
|
155
|
+
path = path.substring(0, hashIndex);
|
|
149
156
|
}
|
|
150
157
|
return path;
|
|
151
158
|
}
|
package/lib/index.ts
CHANGED
|
@@ -19,37 +19,17 @@ import {
|
|
|
19
19
|
import { ono } from "@jsdevtools/ono";
|
|
20
20
|
import maybe from "./util/maybe.js";
|
|
21
21
|
import type { ParserOptions } from "./options.js";
|
|
22
|
-
import type {
|
|
23
|
-
Plugin,
|
|
24
|
-
$RefsCallback,
|
|
25
|
-
JSONSchema,
|
|
26
|
-
SchemaCallback,
|
|
27
|
-
HTTPResolverOptions,
|
|
28
|
-
FileInfo,
|
|
29
|
-
ResolverOptions,
|
|
30
|
-
JSONSchemaObject,
|
|
31
|
-
} from "./types/index.js";
|
|
22
|
+
import type { $RefsCallback, JSONSchema, SchemaCallback } from "./types/index.js";
|
|
32
23
|
|
|
33
|
-
export {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
FileInfo,
|
|
41
|
-
UnmatchedParserError,
|
|
42
|
-
ParserOptions,
|
|
43
|
-
MissingPointerError,
|
|
44
|
-
InvalidPointerError,
|
|
45
|
-
JSONParserError,
|
|
46
|
-
Plugin,
|
|
47
|
-
JSONSchema,
|
|
48
|
-
$RefsCallback,
|
|
49
|
-
SchemaCallback,
|
|
50
|
-
};
|
|
24
|
+
export { JSONParserError };
|
|
25
|
+
export { InvalidPointerError };
|
|
26
|
+
export { MissingPointerError };
|
|
27
|
+
export { ResolverError };
|
|
28
|
+
export { ParserError };
|
|
29
|
+
export { UnmatchedParserError };
|
|
30
|
+
export { UnmatchedResolverError };
|
|
51
31
|
|
|
52
|
-
|
|
32
|
+
type RefParserSchema = string | JSONSchema;
|
|
53
33
|
|
|
54
34
|
/**
|
|
55
35
|
* This class parses a JSON schema, builds a map of its JSON references and their resolved values,
|
package/lib/normalize-args.ts
CHANGED
|
@@ -39,6 +39,11 @@ function normalizeArgs(_args: Partial<IArguments>) {
|
|
|
39
39
|
console.log(e);
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
+
if (!options.mutateInputSchema) {
|
|
43
|
+
// Make a deep clone of the schema, so that we don't alter the original object
|
|
44
|
+
schema = JSON.parse(JSON.stringify(schema));
|
|
45
|
+
}
|
|
46
|
+
|
|
42
47
|
return {
|
|
43
48
|
path,
|
|
44
49
|
schema,
|
package/lib/options.ts
CHANGED
|
@@ -91,6 +91,13 @@ interface $RefParserOptions {
|
|
|
91
91
|
* Default: `relative`
|
|
92
92
|
*/
|
|
93
93
|
externalReferenceResolution?: "relative" | "root";
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Whether to clone the schema before dereferencing it.
|
|
97
|
+
* This is useful when you want to dereference the same schema multiple times, but you don't want to modify the original schema.
|
|
98
|
+
* Default: `true` due to mutating the input being the default behavior historically
|
|
99
|
+
*/
|
|
100
|
+
mutateInputSchema?: boolean;
|
|
94
101
|
};
|
|
95
102
|
}
|
|
96
103
|
|
|
@@ -159,6 +166,8 @@ const getDefaults = () => {
|
|
|
159
166
|
excludedPathMatcher: () => false,
|
|
160
167
|
referenceResolution: "relative",
|
|
161
168
|
},
|
|
169
|
+
|
|
170
|
+
mutateInputSchema: true,
|
|
162
171
|
} as $RefParserOptions;
|
|
163
172
|
return defaults;
|
|
164
173
|
};
|
package/lib/parse.ts
CHANGED
|
@@ -19,7 +19,13 @@ export default parse;
|
|
|
19
19
|
*/
|
|
20
20
|
async function parse(path: string, $refs: $Refs, options: Options) {
|
|
21
21
|
// Remove the URL fragment, if any
|
|
22
|
-
|
|
22
|
+
const hashIndex = path.indexOf("#");
|
|
23
|
+
let hash = "";
|
|
24
|
+
if (hashIndex >= 0) {
|
|
25
|
+
hash = path.substring(hashIndex);
|
|
26
|
+
// Remove the URL fragment, if any
|
|
27
|
+
path = path.substring(0, hashIndex);
|
|
28
|
+
}
|
|
23
29
|
|
|
24
30
|
// Add a new $Ref for this file, even though we don't have the value yet.
|
|
25
31
|
// This ensures that we don't simultaneously read & parse the same file multiple times
|
|
@@ -28,6 +34,7 @@ async function parse(path: string, $refs: $Refs, options: Options) {
|
|
|
28
34
|
// This "file object" will be passed to all resolvers and parsers.
|
|
29
35
|
const file = {
|
|
30
36
|
url: path,
|
|
37
|
+
hash,
|
|
31
38
|
extension: url.getExtension(path),
|
|
32
39
|
} as FileInfo;
|
|
33
40
|
|
|
@@ -103,8 +110,6 @@ async function readFile(file: FileInfo, options: Options, $refs: $Refs): Promise
|
|
|
103
110
|
* The promise resolves with the parsed file contents and the parser that was used.
|
|
104
111
|
*/
|
|
105
112
|
async function parseFile(file: FileInfo, options: Options, $refs: $Refs) {
|
|
106
|
-
// console.log('Parsing %s', file.url);
|
|
107
|
-
|
|
108
113
|
// Find the parsers that can read this file type.
|
|
109
114
|
// If none of the parsers are an exact match for this file, then we'll try ALL of them.
|
|
110
115
|
// This handles situations where the file IS a supported type, just with an unknown extension.
|
package/lib/pointer.ts
CHANGED
|
@@ -190,9 +190,9 @@ class Pointer {
|
|
|
190
190
|
* @param [originalPath]
|
|
191
191
|
* @returns
|
|
192
192
|
*/
|
|
193
|
-
static parse(path: string, originalPath?: string) {
|
|
193
|
+
static parse(path: string, originalPath?: string): string[] {
|
|
194
194
|
// Get the JSON pointer from the path's hash
|
|
195
|
-
|
|
195
|
+
const pointer = url.getHash(path).substring(1);
|
|
196
196
|
|
|
197
197
|
// If there's no pointer, then there are no tokens,
|
|
198
198
|
// so return an empty array
|
|
@@ -201,18 +201,18 @@ class Pointer {
|
|
|
201
201
|
}
|
|
202
202
|
|
|
203
203
|
// Split into an array
|
|
204
|
-
|
|
204
|
+
const split = pointer.split("/");
|
|
205
205
|
|
|
206
206
|
// Decode each part, according to RFC 6901
|
|
207
|
-
for (let i = 0; i <
|
|
208
|
-
|
|
207
|
+
for (let i = 0; i < split.length; i++) {
|
|
208
|
+
split[i] = safeDecodeURIComponent(split[i].replace(escapedSlash, "/").replace(escapedTilde, "~"));
|
|
209
209
|
}
|
|
210
210
|
|
|
211
|
-
if (
|
|
212
|
-
throw new InvalidPointerError(
|
|
211
|
+
if (split[0] !== "") {
|
|
212
|
+
throw new InvalidPointerError(split, originalPath === undefined ? path : originalPath);
|
|
213
213
|
}
|
|
214
214
|
|
|
215
|
-
return
|
|
215
|
+
return split.slice(1);
|
|
216
216
|
}
|
|
217
217
|
|
|
218
218
|
/**
|
package/lib/types/index.ts
CHANGED
|
@@ -130,6 +130,11 @@ export interface FileInfo {
|
|
|
130
130
|
*/
|
|
131
131
|
url: string;
|
|
132
132
|
|
|
133
|
+
/**
|
|
134
|
+
* The hash (URL fragment) of the file URL, including the # symbol. If the URL doesn't have a hash, then this will be an empty string.
|
|
135
|
+
*/
|
|
136
|
+
hash: string;
|
|
137
|
+
|
|
133
138
|
/**
|
|
134
139
|
* The lowercase file extension, such as ".json", ".yaml", ".txt", etc.
|
|
135
140
|
*/
|
package/lib/util/url.ts
CHANGED
|
@@ -28,12 +28,13 @@ export const parse = (u: string | URL) => new URL(u);
|
|
|
28
28
|
export function resolve(from: string, to: string) {
|
|
29
29
|
const fromUrl = new URL(convertPathToPosix(from), "resolve://");
|
|
30
30
|
const resolvedUrl = new URL(convertPathToPosix(to), fromUrl);
|
|
31
|
+
const endSpaces = to.match(/(\s*)$/)?.[1] || "";
|
|
31
32
|
if (resolvedUrl.protocol === "resolve:") {
|
|
32
33
|
// `from` is a relative URL.
|
|
33
34
|
const { pathname, search, hash } = resolvedUrl;
|
|
34
|
-
return pathname + search + hash;
|
|
35
|
+
return pathname + search + hash + endSpaces;
|
|
35
36
|
}
|
|
36
|
-
return resolvedUrl.toString();
|
|
37
|
+
return resolvedUrl.toString() + endSpaces;
|
|
37
38
|
}
|
|
38
39
|
|
|
39
40
|
/**
|
|
@@ -105,10 +106,13 @@ export function stripQuery(path: any) {
|
|
|
105
106
|
* @param path
|
|
106
107
|
* @returns
|
|
107
108
|
*/
|
|
108
|
-
export function getHash(path:
|
|
109
|
+
export function getHash(path: undefined | string) {
|
|
110
|
+
if (!path) {
|
|
111
|
+
return "#";
|
|
112
|
+
}
|
|
109
113
|
const hashIndex = path.indexOf("#");
|
|
110
114
|
if (hashIndex >= 0) {
|
|
111
|
-
return path.
|
|
115
|
+
return path.substring(hashIndex);
|
|
112
116
|
}
|
|
113
117
|
return "#";
|
|
114
118
|
}
|
|
@@ -119,10 +123,13 @@ export function getHash(path: any) {
|
|
|
119
123
|
* @param path
|
|
120
124
|
* @returns
|
|
121
125
|
*/
|
|
122
|
-
export function stripHash(path
|
|
126
|
+
export function stripHash(path?: string | undefined) {
|
|
127
|
+
if (!path) {
|
|
128
|
+
return "";
|
|
129
|
+
}
|
|
123
130
|
const hashIndex = path.indexOf("#");
|
|
124
131
|
if (hashIndex >= 0) {
|
|
125
|
-
path = path.
|
|
132
|
+
path = path.substring(0, hashIndex);
|
|
126
133
|
}
|
|
127
134
|
return path;
|
|
128
135
|
}
|
|
@@ -133,7 +140,7 @@ export function stripHash(path: any) {
|
|
|
133
140
|
* @param path
|
|
134
141
|
* @returns
|
|
135
142
|
*/
|
|
136
|
-
export function isHttp(path:
|
|
143
|
+
export function isHttp(path: string) {
|
|
137
144
|
const protocol = getProtocol(path);
|
|
138
145
|
if (protocol === "http" || protocol === "https") {
|
|
139
146
|
return true;
|