exacturi 1.0.0 → 1.0.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.
Files changed (67) hide show
  1. package/README.md +1 -0
  2. package/dist/cjs/errors.d.ts.map +1 -1
  3. package/dist/cjs/errors.js.map +1 -1
  4. package/dist/cjs/exacturi.d.ts +10 -13
  5. package/dist/cjs/exacturi.d.ts.map +1 -1
  6. package/dist/cjs/exacturi.js +10 -13
  7. package/dist/cjs/exacturi.js.map +1 -1
  8. package/dist/cjs/index.d.ts +6 -4
  9. package/dist/cjs/index.d.ts.map +1 -1
  10. package/dist/cjs/index.js +1 -0
  11. package/dist/cjs/index.js.map +1 -1
  12. package/dist/cjs/package.json +1 -0
  13. package/dist/cjs/parts.d.ts +1 -3
  14. package/dist/cjs/parts.d.ts.map +1 -1
  15. package/dist/cjs/utils.js.map +1 -1
  16. package/dist/esm/errors.d.ts.map +1 -1
  17. package/dist/esm/errors.js.map +1 -1
  18. package/dist/esm/exacturi.d.ts +10 -13
  19. package/dist/esm/exacturi.d.ts.map +1 -1
  20. package/dist/esm/exacturi.js +10 -13
  21. package/dist/esm/exacturi.js.map +1 -1
  22. package/dist/esm/index.d.ts +6 -4
  23. package/dist/esm/index.d.ts.map +1 -1
  24. package/dist/esm/index.js +1 -0
  25. package/dist/esm/index.js.map +1 -1
  26. package/dist/esm/package.json +1 -0
  27. package/dist/esm/parts.d.ts +1 -3
  28. package/dist/esm/parts.d.ts.map +1 -1
  29. package/dist/esm/utils.js.map +1 -1
  30. package/package.json +3 -3
  31. package/src/errors.ts +8 -8
  32. package/src/exacturi.ts +158 -161
  33. package/src/index.ts +15 -13
  34. package/src/parts.ts +10 -12
  35. package/src/utils.ts +16 -16
  36. package/dist/cjs/reuri.d.ts +0 -92
  37. package/dist/cjs/reuri.d.ts.map +0 -1
  38. package/dist/cjs/reuri.js +0 -345
  39. package/dist/cjs/reuri.js.map +0 -1
  40. package/dist/esm/reuri.d.ts +0 -92
  41. package/dist/esm/reuri.d.ts.map +0 -1
  42. package/dist/esm/reuri.js +0 -341
  43. package/dist/esm/reuri.js.map +0 -1
  44. package/dist/lib/errors.d.ts +0 -14
  45. package/dist/lib/errors.d.ts.map +0 -1
  46. package/dist/lib/errors.js +0 -52
  47. package/dist/lib/index.d.ts +0 -31
  48. package/dist/lib/index.d.ts.map +0 -1
  49. package/dist/lib/index.js +0 -20
  50. package/dist/lib/parts.d.ts +0 -18
  51. package/dist/lib/parts.d.ts.map +0 -1
  52. package/dist/lib/parts.js +0 -3
  53. package/dist/lib/payload.d.ts +0 -17
  54. package/dist/lib/payload.d.ts.map +0 -1
  55. package/dist/lib/payload.js +0 -126
  56. package/dist/lib/reuri.d.ts +0 -127
  57. package/dist/lib/reuri.d.ts.map +0 -1
  58. package/dist/lib/reuri.js +0 -457
  59. package/dist/lib/utils.d.ts +0 -2
  60. package/dist/lib/utils.d.ts.map +0 -1
  61. package/dist/lib/utils.js +0 -26
  62. package/dist/test/basic.test.js +0 -319
  63. package/dist/test/basic.test.js.map +0 -1
  64. package/dist/test/extras.test.js +0 -77
  65. package/dist/test/extras.test.js.map +0 -1
  66. package/dist/test/matching.test.js +0 -80
  67. package/dist/test/matching.test.js.map +0 -1
package/src/parts.ts CHANGED
@@ -12,18 +12,16 @@ export type ExactUri_Protocol =
12
12
  | "javascript"
13
13
  | "file"
14
14
  | "ftp"
15
- | string;
16
- export type ExactUri_CompoundNames = "host" | "origin" | "resource" | "address";
17
- export type ExactUri_PathKey = keyof ExactUri_Parts | ExactUri_CompoundNames;
15
+ | string
16
+ export type ExactUri_CompoundNames = "host" | "origin" | "resource" | "address"
17
+ export type ExactUri_PathKey = keyof ExactUri_Parts | ExactUri_CompoundNames
18
18
 
19
- /**
20
- * Describes the parts of a URI.
21
- */
19
+ /** Describes the parts of a URI. */
22
20
  export interface ExactUri_Parts {
23
- protocol?: ExactUri_Protocol;
24
- hostname?: string;
25
- port?: string;
26
- path: string;
27
- query?: string;
28
- hash?: string;
21
+ protocol?: ExactUri_Protocol
22
+ hostname?: string
23
+ port?: string
24
+ path: string
25
+ query?: string
26
+ hash?: string
29
27
  }
package/src/utils.ts CHANGED
@@ -1,42 +1,42 @@
1
1
  export function hostnameContains(child: string | undefined, parent: string) {
2
2
  if (!child) {
3
- return false;
3
+ return false
4
4
  }
5
- const parentParts = parent.split(".").reverse();
6
- const childParts = child.split(".").reverse();
5
+ const parentParts = parent.split(".").reverse()
6
+ const childParts = child.split(".").reverse()
7
7
  if (parentParts.length > childParts.length) {
8
- return false;
8
+ return false
9
9
  }
10
10
 
11
11
  for (let i = 0; i < parentParts.length; i++) {
12
12
  if (!parentParts[i]) {
13
- continue;
13
+ continue
14
14
  }
15
15
  if (childParts[i] !== parentParts[i]) {
16
- return false;
16
+ return false
17
17
  }
18
18
  }
19
- return true;
19
+ return true
20
20
  }
21
21
 
22
22
  export function equal(a: any, b: any): boolean {
23
23
  if (!a || typeof a !== "object" || !b || typeof b !== "object") {
24
- return a === b;
24
+ return a === b
25
25
  }
26
- const aProto = Object.getPrototypeOf(a);
27
- const bProto = Object.getPrototypeOf(b);
26
+ const aProto = Object.getPrototypeOf(a)
27
+ const bProto = Object.getPrototypeOf(b)
28
28
  if (aProto !== bProto) {
29
- return false;
29
+ return false
30
30
  }
31
- const aKeys = Object.keys(a);
32
- const bKeys = Object.keys(b);
31
+ const aKeys = Object.keys(a)
32
+ const bKeys = Object.keys(b)
33
33
  if (aKeys.length !== bKeys.length) {
34
- return false;
34
+ return false
35
35
  }
36
36
  for (const key of aKeys) {
37
37
  if (a[key] !== b[key]) {
38
- return false;
38
+ return false
39
39
  }
40
40
  }
41
- return true;
41
+ return true
42
42
  }
@@ -1,92 +0,0 @@
1
- import { ExactUriParts, ExactUriPathKey, Protocol } from "./parts.js";
2
- /**
3
- * Represents a URI and allows performing operations and inspecting it.
4
- *
5
- * This class is immutable.
6
- */
7
- export declare class ExactUri {
8
- private _protocol;
9
- private _hostname;
10
- private _path;
11
- private _query;
12
- private _hash;
13
- private _parsed;
14
- private _port;
15
- private 0;
16
- constructor(_protocol: Protocol | undefined, _hostname: string | undefined, _path: string, _query: string | undefined, _hash: string | undefined, _parsed: string | undefined, _port: string | undefined);
17
- static isExactUri(other: unknown): boolean;
18
- segments(): string[];
19
- segments(overwrite: string[]): ExactUri;
20
- merge(other: string): ExactUri;
21
- merge(other: ExactUri): ExactUri;
22
- pick(...keys: ExactUriPathKey[]): ExactUri;
23
- parts(): ExactUriParts;
24
- parts(overwrite: Partial<ExactUriParts>): ExactUri;
25
- part(key: ExactUriPathKey): string | undefined;
26
- part(key: ExactUriPathKey, value: string | undefined): ExactUri;
27
- address(address: string | undefined | null): ExactUri;
28
- address(): string | undefined;
29
- resource(resource: string | undefined | null): ExactUri;
30
- resource(): string | undefined;
31
- origin(origin: string | undefined | null): ExactUri;
32
- origin(): string | undefined;
33
- segment(index: number): string;
34
- segment(index: number, value: string): ExactUri;
35
- path(): string;
36
- path(path: string | undefined | null): ExactUri;
37
- port(): number | undefined;
38
- port(raw: true): string | undefined;
39
- port(port: number | undefined | string | null): ExactUri;
40
- protocol(): Protocol | undefined;
41
- protocol(proto: Protocol | null | undefined): ExactUri;
42
- host(): string | undefined;
43
- host(host: string | undefined | null): ExactUri;
44
- hostname(): string | undefined;
45
- hostname(hostname: string | undefined | null): ExactUri;
46
- query(): string | undefined;
47
- query(query: string | null | undefined): ExactUri;
48
- hash(): string;
49
- hash(hash: string | null | undefined): ExactUri;
50
- private _noCopyClone;
51
- get isWeb(): boolean;
52
- /**
53
- * Gets a clone of this instance.
54
- */
55
- clone(): ExactUri;
56
- static empty(): ExactUri;
57
- static parse(input: null | undefined): ExactUri;
58
- static parse(input: string | ExactUri | Partial<ExactUriParts>): ExactUri;
59
- /**
60
- * Checks if this URI (CHILD) matches another URI (PARENT). The parent can be a string,
61
- * an {@link ExactUri}, or an object describing the parts of a URI -- an {@link ExactUriParts}.
62
- *
63
- * CHILD is considered to be a child of PARENT if:
64
- * 1. If PARENT has a protocol, it must equal CHILD protocol.
65
- * 2. If PARENT has a hostname, it must be a parent of CHILD's hostname.
66
- * 3. If PARENT has a port, it must equal CHILD's port.
67
- * 4. If PARENT has a path, it must be a parent of CHILD's path.
68
- * 5. If PARENT has a query, it must equal CHILD's query.
69
- * 6. If PARENT has a hash, it must equal CHILD's hash.
70
- * @param parent The parent URI to check against.
71
- */
72
- matches(parent: Partial<ExactUriParts> | ExactUri | string): boolean;
73
- /**
74
- * Checks if this URI equals another URI, which can be given as a string, an
75
- * {@link ExactUri}, or an object describing the parts of a URI -- an {@link ExactUriParts}.
76
- * @param other The other URI to check against.
77
- */
78
- equal(other: string | ExactUri | Partial<ExactUriParts>): boolean;
79
- get isArtificial(): boolean;
80
- /**
81
- * Does this URL have a non-web protocol?
82
- */
83
- get isNonWeb(): boolean;
84
- /**
85
- * Gets the full URI.
86
- */
87
- get href(): string;
88
- private _print;
89
- get [Symbol.toStringTag](): string;
90
- toString(): string;
91
- }
92
- //# sourceMappingURL=reuri.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"reuri.d.ts","sourceRoot":"","sources":["../../src/reuri.ts"],"names":[],"mappings":"AAEA,OAAO,EAAyB,aAAa,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE7F;;;;GAIG;AACH,qBAAa,QAAQ;IAKb,OAAO,CAAC,SAAS;IACjB,OAAO,CAAC,SAAS;IACjB,OAAO,CAAC,KAAK;IACb,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,KAAK;IACb,OAAO,CAAC,OAAO;IACf,OAAO,CAAC,KAAK;IAVjB,OAAO,CAAC,CAAC,CAAS;gBAIN,SAAS,EAAE,QAAQ,GAAG,SAAS,EAC/B,SAAS,EAAE,MAAM,GAAG,SAAS,EAC7B,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,GAAG,SAAS,EAC1B,KAAK,EAAE,MAAM,GAAG,SAAS,EACzB,OAAO,EAAE,MAAM,GAAG,S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,QAAQ,YAEX;IAED;;OAEG;IACH,IAAI,IAAI,WAEP;IAED,OAAO,CAAC,MAAM;IAWd,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,WAEvB;IAED,QAAQ;CAGX"}
package/dist/cjs/reuri.js DELETED
@@ -1,345 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ExactUri = void 0;
4
- const errors_js_1 = require("./errors.js");
5
- const utils_js_1 = require("./utils.js");
6
- /**
7
- * Represents a URI and allows performing operations and inspecting it.
8
- *
9
- * This class is immutable.
10
- */
11
- class ExactUri {
12
- // Lots of params needed here
13
- // eslint-disable-next-line max-params
14
- constructor(_protocol, _hostname, _path, _query, _hash, _parsed, _port) {
15
- this._protocol = _protocol;
16
- this._hostname = _hostname;
17
- this._path = _path;
18
- this._query = _query;
19
- this._hash = _hash;
20
- this._parsed = _parsed;
21
- this._port = _port;
22
- if (_hostname) {
23
- this._hostname = _hostname.replace("_", ".");
24
- if (this._hostname.includes("_")) {
25
- console.warn(`The hostname contains multiple underscores, which might not be intended. Current hostname: ${this._hostname}`);
26
- }
27
- }
28
- this[0] = this._print();
29
- }
30
- static isExactUri(other) {
31
- return !!(other &&
32
- typeof other === "object" &&
33
- other.constructor &&
34
- "__isExactUri" in other.constructor);
35
- }
36
- segments(overwrite) {
37
- if (arguments.length === 0) {
38
- return this._path.split("/");
39
- }
40
- const clone = this._noCopyClone();
41
- clone._path = overwrite.join("/");
42
- return clone;
43
- }
44
- merge(other) {
45
- if (typeof other === "string") {
46
- return this.merge(ExactUri.parse(other));
47
- }
48
- return this.parts({
49
- hash: other._hash || this._hash,
50
- hostname: other._hostname || this._hostname,
51
- path: other._path || this._path,
52
- port: other._port || this._port,
53
- protocol: other._protocol || this._protocol,
54
- query: other._query || this._query
55
- });
56
- }
57
- pick(...keys) {
58
- let result = ExactUri.empty();
59
- for (const key of keys) {
60
- result = result.part(key, this.part(key));
61
- }
62
- return result;
63
- }
64
- parts(overwrite) {
65
- if (arguments.length === 0) {
66
- return {
67
- protocol: this._protocol,
68
- hostname: this._hostname,
69
- port: this._port,
70
- path: this._path,
71
- query: this._query,
72
- hash: this._hash
73
- };
74
- }
75
- if (!overwrite) {
76
- return this;
77
- }
78
- const clone = this._noCopyClone();
79
- clone._protocol = "protocol" in overwrite ? overwrite.protocol : clone._protocol;
80
- clone._hostname = "hostname" in overwrite ? overwrite.hostname : clone._hostname;
81
- clone._port = "port" in overwrite ? overwrite.port : clone._port;
82
- clone._path = "path" in overwrite ? overwrite.path : clone._path;
83
- clone._query = "query" in overwrite ? overwrite.query : clone._query;
84
- clone._hash = "hash" in overwrite ? overwrite.hash : clone._hash;
85
- return clone;
86
- }
87
- part(key, value) {
88
- if (arguments.length === 1) {
89
- const result = this[key]();
90
- return result != null ? String(result) : undefined;
91
- }
92
- return this[key](value);
93
- }
94
- address(address) {
95
- if (arguments.length === 1) {
96
- const parsed = ExactUri.parse(address);
97
- return parsed.parts({
98
- protocol: this._protocol
99
- });
100
- }
101
- return this.parts({
102
- protocol: undefined
103
- }).href;
104
- }
105
- resource(resource) {
106
- if (arguments.length === 1) {
107
- const parsed = ExactUri.parse(resource);
108
- return parsed.parts({
109
- protocol: this._protocol,
110
- hostname: this._hostname,
111
- port: this._port
112
- });
113
- }
114
- return this.parts({
115
- protocol: undefined,
116
- hostname: undefined,
117
- port: undefined
118
- }).href;
119
- }
120
- origin(origin) {
121
- if (arguments.length === 1) {
122
- const parsed = ExactUri.parse(origin);
123
- return this.parts({
124
- protocol: parsed._protocol,
125
- hostname: parsed._hostname,
126
- port: parsed._port
127
- });
128
- }
129
- const parts = this.parts();
130
- return (ExactUri.empty().parts({
131
- protocol: parts.protocol,
132
- hostname: parts.hostname,
133
- port: parts.port
134
- }).href || undefined);
135
- }
136
- segment(index, value) {
137
- if (arguments.length === 0) {
138
- throw new errors_js_1.ExactUriError(`You must provide an index.`);
139
- }
140
- if (arguments.length === 1) {
141
- return this._path.split("/")[index];
142
- }
143
- const segments = this.segments();
144
- segments[index] = value;
145
- return this.segments(segments);
146
- }
147
- path(path) {
148
- if (arguments.length === 0) {
149
- return this._path;
150
- }
151
- const clone = this._noCopyClone();
152
- clone._path = path ?? "";
153
- return clone;
154
- }
155
- port(port) {
156
- if (arguments.length === 0) {
157
- return this._port != null ? Number(this._port) : undefined;
158
- }
159
- if (port === true) {
160
- return this._port;
161
- }
162
- const clone = this._noCopyClone();
163
- clone._port = port != null ? String(port) : undefined;
164
- return clone;
165
- }
166
- protocol(proto) {
167
- if (arguments.length === 0) {
168
- return this._protocol;
169
- }
170
- const clone = this._noCopyClone();
171
- clone._protocol = proto ?? undefined;
172
- return clone;
173
- }
174
- host(host) {
175
- if (arguments.length === 0) {
176
- return (ExactUri.empty().hostname(this._hostname).port(this._port).href.slice(2) ||
177
- undefined);
178
- }
179
- if (host == null) {
180
- return this.hostname(null).port(null);
181
- }
182
- const parsed = ExactUri.parse(`//${host}`);
183
- return this.hostname(parsed._hostname).port(parsed._port);
184
- }
185
- hostname(hostname) {
186
- if (arguments.length === 0) {
187
- return this._hostname;
188
- }
189
- const clone = this._noCopyClone();
190
- clone._hostname = hostname ?? undefined;
191
- return clone;
192
- }
193
- query(query) {
194
- if (arguments.length === 0) {
195
- return this._query;
196
- }
197
- const clone = this._noCopyClone();
198
- clone._query = query ?? undefined;
199
- return clone;
200
- }
201
- hash(hash) {
202
- if (arguments.length === 0) {
203
- return this._hash;
204
- }
205
- const clone = this._noCopyClone();
206
- clone._hash = hash ?? undefined;
207
- return clone;
208
- }
209
- _noCopyClone() {
210
- return new ExactUri(this._protocol, this._hostname, this._path, this._query, this._hash, this._parsed, this._port);
211
- }
212
- // Does this URL have a web protocol?
213
- get isWeb() {
214
- return !!this._protocol && webProtocols.has(this._protocol);
215
- }
216
- /**
217
- * Gets a clone of this instance.
218
- */
219
- clone() {
220
- return new ExactUri(this._protocol, this._hostname, this._path, this._query, this._hash, this._parsed, this._port);
221
- }
222
- static empty() {
223
- return new ExactUri(undefined, undefined, "", undefined, undefined, undefined, undefined);
224
- }
225
- static parse(input) {
226
- if (input == null) {
227
- return ExactUri.empty();
228
- }
229
- if (input instanceof ExactUri) {
230
- return input;
231
- }
232
- if (typeof input === "object") {
233
- return ExactUri.empty().parts(input);
234
- }
235
- if (typeof input !== "string") {
236
- throw (0, errors_js_1.inputMustBeString)(input);
237
- }
238
- const r = urlRegexp.exec(input);
239
- if (!r) {
240
- throw (0, errors_js_1.inputMustBeUrl)(input);
241
- }
242
- const [, proto, hostname, port, path, query, fragment] = r;
243
- if (port != null && (Number.isNaN(+port) || port === "")) {
244
- throw (0, errors_js_1.portMustBeNumeric)(input);
245
- }
246
- return new ExactUri(proto?.trim(), hostname?.trim(), path?.trim() ?? "", query?.trim(), fragment?.trim(), input, port);
247
- }
248
- /**
249
- * Checks if this URI (CHILD) matches another URI (PARENT). The parent can be a string,
250
- * an {@link ExactUri}, or an object describing the parts of a URI -- an {@link ExactUriParts}.
251
- *
252
- * CHILD is considered to be a child of PARENT if:
253
- * 1. If PARENT has a protocol, it must equal CHILD protocol.
254
- * 2. If PARENT has a hostname, it must be a parent of CHILD's hostname.
255
- * 3. If PARENT has a port, it must equal CHILD's port.
256
- * 4. If PARENT has a path, it must be a parent of CHILD's path.
257
- * 5. If PARENT has a query, it must equal CHILD's query.
258
- * 6. If PARENT has a hash, it must equal CHILD's hash.
259
- * @param parent The parent URI to check against.
260
- */
261
- matches(parent) {
262
- parent = ExactUri.parse(parent);
263
- if (parent._protocol && parent._protocol !== this._protocol) {
264
- return false;
265
- }
266
- if (parent._hostname && !(0, utils_js_1.hostnameContains)(this._hostname, parent._hostname)) {
267
- return false;
268
- }
269
- if (parent._port && parent._port !== this._port) {
270
- return false;
271
- }
272
- if (parent._query && parent._query !== this._query) {
273
- return false;
274
- }
275
- if (parent._hash && parent._hash !== this._hash) {
276
- return false;
277
- }
278
- const parentSegments = parent.segments();
279
- const childSegments = this.segments();
280
- for (let i = 0; i < parentSegments.length; i++) {
281
- if (parentSegments[i] !== childSegments[i]) {
282
- return false;
283
- }
284
- }
285
- return true;
286
- }
287
- /**
288
- * Checks if this URI equals another URI, which can be given as a string, an
289
- * {@link ExactUri}, or an object describing the parts of a URI -- an {@link ExactUriParts}.
290
- * @param other The other URI to check against.
291
- */
292
- equal(other) {
293
- if (this === other) {
294
- return true;
295
- }
296
- other = ExactUri.parse(other);
297
- const myParts = this.parts();
298
- const otherParts = other.parts();
299
- for (const key of ["protocol", "hostname", "port", "path", "query", "hash"]) {
300
- if (myParts[key] !== otherParts[key]) {
301
- return false;
302
- }
303
- }
304
- return true;
305
- }
306
- // An artificial URI is one that can't have been parsed from a string due to an invalid combination of components.
307
- get isArtificial() {
308
- return !ExactUri.parse(this._print()).equal(this);
309
- }
310
- /**
311
- * Does this URL have a non-web protocol?
312
- */
313
- get isNonWeb() {
314
- return !!this._protocol && !webProtocols.has(this._protocol);
315
- }
316
- /**
317
- * Gets the full URI.
318
- */
319
- get href() {
320
- return this._print();
321
- }
322
- _print() {
323
- let { _protocol, _hostname, _query, _hash } = this;
324
- const { _port } = this;
325
- _protocol = _protocol != null ? `${_protocol}:` : _protocol;
326
- _hostname = _hostname != null ? `//${_hostname}` : "";
327
- _query = _query != null ? `?${_query}` : "";
328
- _hash = _hash != null ? `#${_hash}` : "";
329
- const strPort = _port != null ? `:${_port}` : "";
330
- return [_protocol, _hostname, strPort, this._path, _query, _hash].join("");
331
- }
332
- get [Symbol.toStringTag]() {
333
- return this.href;
334
- }
335
- toString() {
336
- return this.href;
337
- }
338
- }
339
- exports.ExactUri = ExactUri;
340
- const urlRegexp = /^(?:([a-zA-Z][A-Za-z\d+-.]*):)?(?:\/\/([^/?#:]*)(?::([^/?#]*))?)?([^?#]*)?(?:\?([^#]*))?(?:#(.*))?$/;
341
- const webProtocols = new Set(["http", "ws", "https", "wss"]);
342
- Object.defineProperty(ExactUri, "__isExactUri", {
343
- value: true
344
- });
345
- //# sourceMappingURL=reuri.js.map
@@ -1 +0,0 @@
1
- {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";
2
- /**
3
- * Represents a URI and allows performing operations and inspecting it.
4
- *
5
- * This class is immutable.
6
- */
7
- export declare class ExactUri {
8
- private _protocol;
9
- private _hostname;
10
- private _path;
11
- private _query;
12
- private _hash;
13
- private _parsed;
14
- private _port;
15
- private 0;
16
- constructor(_protocol: Protocol | undefined, _hostname: string | undefined, _path: string, _query: string | undefined, _hash: string | undefined, _parsed: string | undefined, _port: string | undefined);
17
- static isExactUri(other: unknown): boolean;
18
- segments(): string[];
19
- segments(overwrite: string[]): ExactUri;
20
- merge(other: string): ExactUri;
21
- merge(other: ExactUri): ExactUri;
22
- pick(...keys: ExactUriPathKey[]): ExactUri;
23
- parts(): ExactUriParts;
24
- parts(overwrite: Partial<ExactUriParts>): ExactUri;
25
- part(key: ExactUriPathKey): string | undefined;
26
- part(key: ExactUriPathKey, value: string | undefined): ExactUri;
27
- address(address: string | undefined | null): ExactUri;
28
- address(): string | undefined;
29
- resource(resource: string | undefined | null): ExactUri;
30
- resource(): string | undefined;
31
- origin(origin: string | undefined | null): ExactUri;
32
- origin(): string | undefined;
33
- segment(index: number): string;
34
- segment(index: number, value: string): ExactUri;
35
- path(): string;
36
- path(path: string | undefined | null): ExactUri;
37
- port(): number | undefined;
38
- port(raw: true): string | undefined;
39
- port(port: number | undefined | string | null): ExactUri;
40
- protocol(): Protocol | undefined;
41
- protocol(proto: Protocol | null | undefined): ExactUri;
42
- host(): string | undefined;
43
- host(host: string | undefined | null): ExactUri;
44
- hostname(): string | undefined;
45
- hostname(hostname: string | undefined | null): ExactUri;
46
- query(): string | undefined;
47
- query(query: string | null | undefined): ExactUri;
48
- hash(): string;
49
- hash(hash: string | null | undefined): ExactUri;
50
- private _noCopyClone;
51
- get isWeb(): boolean;
52
- /**
53
- * Gets a clone of this instance.
54
- */
55
- clone(): ExactUri;
56
- static empty(): ExactUri;
57
- static parse(input: null | undefined): ExactUri;
58
- static parse(input: string | ExactUri | Partial<ExactUriParts>): ExactUri;
59
- /**
60
- * Checks if this URI (CHILD) matches another URI (PARENT). The parent can be a string,
61
- * an {@link ExactUri}, or an object describing the parts of a URI -- an {@link ExactUriParts}.
62
- *
63
- * CHILD is considered to be a child of PARENT if:
64
- * 1. If PARENT has a protocol, it must equal CHILD protocol.
65
- * 2. If PARENT has a hostname, it must be a parent of CHILD's hostname.
66
- * 3. If PARENT has a port, it must equal CHILD's port.
67
- * 4. If PARENT has a path, it must be a parent of CHILD's path.
68
- * 5. If PARENT has a query, it must equal CHILD's query.
69
- * 6. If PARENT has a hash, it must equal CHILD's hash.
70
- * @param parent The parent URI to check against.
71
- */
72
- matches(parent: Partial<ExactUriParts> | ExactUri | string): boolean;
73
- /**
74
- * Checks if this URI equals another URI, which can be given as a string, an
75
- * {@link ExactUri}, or an object describing the parts of a URI -- an {@link ExactUriParts}.
76
- * @param other The other URI to check against.
77
- */
78
- equal(other: string | ExactUri | Partial<ExactUriParts>): boolean;
79
- get isArtificial(): boolean;
80
- /**
81
- * Does this URL have a non-web protocol?
82
- */
83
- get isNonWeb(): boolean;
84
- /**
85
- * Gets the full URI.
86
- */
87
- get href(): string;
88
- private _print;
89
- get [Symbol.toStringTag](): string;
90
- toString(): string;
91
- }
92
- //# sourceMappingURL=reuri.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"reuri.d.ts","sourceRoot":"","sources":["../../src/reuri.ts"],"names":[],"mappings":"AAEA,OAAO,EAAyB,aAAa,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE7F;;;;GAIG;AACH,qBAAa,QAAQ;IAKb,OAAO,CAAC,SAAS;IACjB,OAAO,CAAC,SAAS;IACjB,OAAO,CAAC,KAAK;IACb,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,KAAK;IACb,OAAO,CAAC,OAAO;IACf,OAAO,CAAC,KAAK;IAVjB,OAAO,CAAC,CAAC,CAAS;gBAIN,SAAS,EAAE,QAAQ,GAAG,SAAS,EAC/B,SAAS,EAAE,MAAM,GAAG,SAAS,EAC7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