@uniformdev/redirect 19.79.0 → 19.79.1-alpha.13
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/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.esm.js +22 -8
- package/dist/index.js +22 -8
- package/dist/index.mjs +22 -8
- package/package.json +3 -3
package/dist/index.d.mts
CHANGED
|
@@ -452,4 +452,4 @@ type ProcessedUrl = {
|
|
|
452
452
|
*/
|
|
453
453
|
declare function processUrl(url: string): ProcessedUrl;
|
|
454
454
|
|
|
455
|
-
export { DirectionAwareRedirectDefinition, ExtractWildcards, PathTrie, PathTrieData, ProcessedUrl, RedirectClient, RedirectClientGetRedirect, RedirectClientGetRedirects, RedirectClientGetRequest, RedirectClientOptions, RedirectDataCache, RedirectDefinition, RedirectDefinitions, RedirectDeleteRequest, RedirectDeleteResponse, RedirectFileConverter, RedirectFileConverterParams, RedirectGetRequest, RedirectGetResponse, RedirectOptions, RedirectResult, RedirectUpsertRequest, RedirectUpsertResponse, SourceAndTarget, SourceTargetAndWildcards, UncachedRedirectClient, Wildcard, WithMemoryCache, getSourceVariables, getTargetVariableExpandedUrl, mergeQueryStrings, pathTrieReturn, processUrl };
|
|
455
|
+
export { type DirectionAwareRedirectDefinition, ExtractWildcards, PathTrie, PathTrieData, type ProcessedUrl, RedirectClient, type RedirectClientGetRedirect, type RedirectClientGetRedirects, type RedirectClientGetRequest, type RedirectClientOptions, type RedirectDataCache, type RedirectDefinition, type RedirectDefinitions, type RedirectDeleteRequest, type RedirectDeleteResponse, RedirectFileConverter, type RedirectFileConverterParams, type RedirectGetRequest, type RedirectGetResponse, type RedirectOptions, type RedirectResult, type RedirectUpsertRequest, type RedirectUpsertResponse, type SourceAndTarget, type SourceTargetAndWildcards, UncachedRedirectClient, type Wildcard, WithMemoryCache, getSourceVariables, getTargetVariableExpandedUrl, mergeQueryStrings, type pathTrieReturn, processUrl };
|
package/dist/index.d.ts
CHANGED
|
@@ -452,4 +452,4 @@ type ProcessedUrl = {
|
|
|
452
452
|
*/
|
|
453
453
|
declare function processUrl(url: string): ProcessedUrl;
|
|
454
454
|
|
|
455
|
-
export { DirectionAwareRedirectDefinition, ExtractWildcards, PathTrie, PathTrieData, ProcessedUrl, RedirectClient, RedirectClientGetRedirect, RedirectClientGetRedirects, RedirectClientGetRequest, RedirectClientOptions, RedirectDataCache, RedirectDefinition, RedirectDefinitions, RedirectDeleteRequest, RedirectDeleteResponse, RedirectFileConverter, RedirectFileConverterParams, RedirectGetRequest, RedirectGetResponse, RedirectOptions, RedirectResult, RedirectUpsertRequest, RedirectUpsertResponse, SourceAndTarget, SourceTargetAndWildcards, UncachedRedirectClient, Wildcard, WithMemoryCache, getSourceVariables, getTargetVariableExpandedUrl, mergeQueryStrings, pathTrieReturn, processUrl };
|
|
455
|
+
export { type DirectionAwareRedirectDefinition, ExtractWildcards, PathTrie, PathTrieData, type ProcessedUrl, RedirectClient, type RedirectClientGetRedirect, type RedirectClientGetRedirects, type RedirectClientGetRequest, type RedirectClientOptions, type RedirectDataCache, type RedirectDefinition, type RedirectDefinitions, type RedirectDeleteRequest, type RedirectDeleteResponse, RedirectFileConverter, type RedirectFileConverterParams, type RedirectGetRequest, type RedirectGetResponse, type RedirectOptions, type RedirectResult, type RedirectUpsertRequest, type RedirectUpsertResponse, type SourceAndTarget, type SourceTargetAndWildcards, UncachedRedirectClient, type Wildcard, WithMemoryCache, getSourceVariables, getTargetVariableExpandedUrl, mergeQueryStrings, type pathTrieReturn, processUrl };
|
package/dist/index.esm.js
CHANGED
|
@@ -260,15 +260,21 @@ import { ApiClient } from "@uniformdev/context/api";
|
|
|
260
260
|
// src/util/url.ts
|
|
261
261
|
function processUrl(url) {
|
|
262
262
|
var _a, _b, _c, _d, _e, _f;
|
|
263
|
-
const matches = url.match(/^(https?:\/\/)?(([^:/?#]*)(?:(:[0-9]+))?)?([/]{0,1}[^?#]*)(\?[
|
|
263
|
+
const matches = url.match(/^(https?:\/\/)?(([^:/?#]*)(?:(:[0-9]+))?)?([/]{0,1}[^?#]*)(\?[^#?]*|)(#.*|)$/);
|
|
264
|
+
const protocol = (_a = matches == null ? void 0 : matches[1]) != null ? _a : "";
|
|
265
|
+
const domain = (_b = matches == null ? void 0 : matches[3]) != null ? _b : "";
|
|
266
|
+
const port = (_c = matches == null ? void 0 : matches[4]) != null ? _c : "";
|
|
267
|
+
const path = (_d = matches == null ? void 0 : matches[5].replace(/\/+$/g, "")) != null ? _d : "";
|
|
268
|
+
const query = (_e = matches == null ? void 0 : matches[6]) != null ? _e : "";
|
|
269
|
+
const fragment = (_f = matches == null ? void 0 : matches[7]) != null ? _f : "";
|
|
264
270
|
return {
|
|
265
|
-
url
|
|
266
|
-
protocol
|
|
267
|
-
domain
|
|
268
|
-
port
|
|
269
|
-
path
|
|
270
|
-
query
|
|
271
|
-
fragment
|
|
271
|
+
url: `${protocol}${domain}${port}${path}${query}${fragment}`,
|
|
272
|
+
protocol,
|
|
273
|
+
domain,
|
|
274
|
+
port,
|
|
275
|
+
path,
|
|
276
|
+
query,
|
|
277
|
+
fragment
|
|
272
278
|
};
|
|
273
279
|
}
|
|
274
280
|
|
|
@@ -328,6 +334,7 @@ function mergeQueryStrings(qs1, qs2) {
|
|
|
328
334
|
var _RedirectClient = class _RedirectClient extends ApiClient {
|
|
329
335
|
constructor(options) {
|
|
330
336
|
super(options);
|
|
337
|
+
// Get a single redirect by ID or project map id
|
|
331
338
|
this.getRedirect = async (options) => {
|
|
332
339
|
var _a;
|
|
333
340
|
const { projectId } = this.options;
|
|
@@ -335,12 +342,14 @@ var _RedirectClient = class _RedirectClient extends ApiClient {
|
|
|
335
342
|
const results = await this.apiClient(fetchUri);
|
|
336
343
|
return (_a = results.redirects) == null ? void 0 : _a[0];
|
|
337
344
|
};
|
|
345
|
+
// Get redirects by list of IDs, source URL, target URL, or search
|
|
338
346
|
this.getRedirects = async (options) => {
|
|
339
347
|
const { projectId } = this.options;
|
|
340
348
|
const fetchUri = this.createUrl("/api/v1/redirect", { ...options, projectId });
|
|
341
349
|
const results = await this.apiClient(fetchUri);
|
|
342
350
|
return results;
|
|
343
351
|
};
|
|
352
|
+
// Assemble a trie powered search structure, used to have instant resolution of redirects. Note, result set may be large.
|
|
344
353
|
this.getRedirectTrie = async (options) => {
|
|
345
354
|
var _a, _b;
|
|
346
355
|
const { projectId } = this.options;
|
|
@@ -432,6 +441,8 @@ var _RedirectClient = class _RedirectClient extends ApiClient {
|
|
|
432
441
|
const trie = await this.getRedirectTrie();
|
|
433
442
|
return (_b = _RedirectClient.processHops(sanitizedUrl, trie, true, options)) == null ? void 0 : _b[0];
|
|
434
443
|
};
|
|
444
|
+
// Caculate redirect matches based on an incoming URL with an option to use a trie storage structure to streamline future
|
|
445
|
+
// redirect resolutions. Note this may cause a large in memory load for large collections of redirect, off by default.
|
|
435
446
|
this.processUrlAllMatches = async (url, options, useTrie) => {
|
|
436
447
|
const sanitizedUrl = url.endsWith("/") ? url.replace(/\/+$/, "") : url;
|
|
437
448
|
if (!useTrie) {
|
|
@@ -464,6 +475,7 @@ var _RedirectClient = class _RedirectClient extends ApiClient {
|
|
|
464
475
|
}
|
|
465
476
|
}
|
|
466
477
|
}
|
|
478
|
+
// Get all redirects in Uniform 500 at a time.
|
|
467
479
|
async *getAllRedirects(orderBy = "updated_at desc") {
|
|
468
480
|
var _a, _b;
|
|
469
481
|
const { projectId } = this.options;
|
|
@@ -512,6 +524,8 @@ var _RedirectClient = class _RedirectClient extends ApiClient {
|
|
|
512
524
|
}
|
|
513
525
|
return await _RedirectClient.assemblingPromise;
|
|
514
526
|
}
|
|
527
|
+
// Find all redirects involved for the current URL, this is for the case where a redirect definition leads to
|
|
528
|
+
// another redirect. This also involves cycle busting error handling
|
|
515
529
|
static processHops(initialUrl, trie, bestMatch, options) {
|
|
516
530
|
const url = (options == null ? void 0 : options.reverse) ? initialUrl.replace(/\/:/, "/~~") : initialUrl;
|
|
517
531
|
const isCycle = (id, result) => {
|
package/dist/index.js
CHANGED
|
@@ -306,15 +306,21 @@ var import_api = require("@uniformdev/context/api");
|
|
|
306
306
|
// src/util/url.ts
|
|
307
307
|
function processUrl(url) {
|
|
308
308
|
var _a, _b, _c, _d, _e, _f;
|
|
309
|
-
const matches = url.match(/^(https?:\/\/)?(([^:/?#]*)(?:(:[0-9]+))?)?([/]{0,1}[^?#]*)(\?[
|
|
309
|
+
const matches = url.match(/^(https?:\/\/)?(([^:/?#]*)(?:(:[0-9]+))?)?([/]{0,1}[^?#]*)(\?[^#?]*|)(#.*|)$/);
|
|
310
|
+
const protocol = (_a = matches == null ? void 0 : matches[1]) != null ? _a : "";
|
|
311
|
+
const domain = (_b = matches == null ? void 0 : matches[3]) != null ? _b : "";
|
|
312
|
+
const port = (_c = matches == null ? void 0 : matches[4]) != null ? _c : "";
|
|
313
|
+
const path = (_d = matches == null ? void 0 : matches[5].replace(/\/+$/g, "")) != null ? _d : "";
|
|
314
|
+
const query = (_e = matches == null ? void 0 : matches[6]) != null ? _e : "";
|
|
315
|
+
const fragment = (_f = matches == null ? void 0 : matches[7]) != null ? _f : "";
|
|
310
316
|
return {
|
|
311
|
-
url
|
|
312
|
-
protocol
|
|
313
|
-
domain
|
|
314
|
-
port
|
|
315
|
-
path
|
|
316
|
-
query
|
|
317
|
-
fragment
|
|
317
|
+
url: `${protocol}${domain}${port}${path}${query}${fragment}`,
|
|
318
|
+
protocol,
|
|
319
|
+
domain,
|
|
320
|
+
port,
|
|
321
|
+
path,
|
|
322
|
+
query,
|
|
323
|
+
fragment
|
|
318
324
|
};
|
|
319
325
|
}
|
|
320
326
|
|
|
@@ -374,6 +380,7 @@ function mergeQueryStrings(qs1, qs2) {
|
|
|
374
380
|
var _RedirectClient = class _RedirectClient extends import_api.ApiClient {
|
|
375
381
|
constructor(options) {
|
|
376
382
|
super(options);
|
|
383
|
+
// Get a single redirect by ID or project map id
|
|
377
384
|
this.getRedirect = async (options) => {
|
|
378
385
|
var _a;
|
|
379
386
|
const { projectId } = this.options;
|
|
@@ -381,12 +388,14 @@ var _RedirectClient = class _RedirectClient extends import_api.ApiClient {
|
|
|
381
388
|
const results = await this.apiClient(fetchUri);
|
|
382
389
|
return (_a = results.redirects) == null ? void 0 : _a[0];
|
|
383
390
|
};
|
|
391
|
+
// Get redirects by list of IDs, source URL, target URL, or search
|
|
384
392
|
this.getRedirects = async (options) => {
|
|
385
393
|
const { projectId } = this.options;
|
|
386
394
|
const fetchUri = this.createUrl("/api/v1/redirect", { ...options, projectId });
|
|
387
395
|
const results = await this.apiClient(fetchUri);
|
|
388
396
|
return results;
|
|
389
397
|
};
|
|
398
|
+
// Assemble a trie powered search structure, used to have instant resolution of redirects. Note, result set may be large.
|
|
390
399
|
this.getRedirectTrie = async (options) => {
|
|
391
400
|
var _a, _b;
|
|
392
401
|
const { projectId } = this.options;
|
|
@@ -478,6 +487,8 @@ var _RedirectClient = class _RedirectClient extends import_api.ApiClient {
|
|
|
478
487
|
const trie = await this.getRedirectTrie();
|
|
479
488
|
return (_b = _RedirectClient.processHops(sanitizedUrl, trie, true, options)) == null ? void 0 : _b[0];
|
|
480
489
|
};
|
|
490
|
+
// Caculate redirect matches based on an incoming URL with an option to use a trie storage structure to streamline future
|
|
491
|
+
// redirect resolutions. Note this may cause a large in memory load for large collections of redirect, off by default.
|
|
481
492
|
this.processUrlAllMatches = async (url, options, useTrie) => {
|
|
482
493
|
const sanitizedUrl = url.endsWith("/") ? url.replace(/\/+$/, "") : url;
|
|
483
494
|
if (!useTrie) {
|
|
@@ -510,6 +521,7 @@ var _RedirectClient = class _RedirectClient extends import_api.ApiClient {
|
|
|
510
521
|
}
|
|
511
522
|
}
|
|
512
523
|
}
|
|
524
|
+
// Get all redirects in Uniform 500 at a time.
|
|
513
525
|
async *getAllRedirects(orderBy = "updated_at desc") {
|
|
514
526
|
var _a, _b;
|
|
515
527
|
const { projectId } = this.options;
|
|
@@ -558,6 +570,8 @@ var _RedirectClient = class _RedirectClient extends import_api.ApiClient {
|
|
|
558
570
|
}
|
|
559
571
|
return await _RedirectClient.assemblingPromise;
|
|
560
572
|
}
|
|
573
|
+
// Find all redirects involved for the current URL, this is for the case where a redirect definition leads to
|
|
574
|
+
// another redirect. This also involves cycle busting error handling
|
|
561
575
|
static processHops(initialUrl, trie, bestMatch, options) {
|
|
562
576
|
const url = (options == null ? void 0 : options.reverse) ? initialUrl.replace(/\/:/, "/~~") : initialUrl;
|
|
563
577
|
const isCycle = (id, result) => {
|
package/dist/index.mjs
CHANGED
|
@@ -260,15 +260,21 @@ import { ApiClient } from "@uniformdev/context/api";
|
|
|
260
260
|
// src/util/url.ts
|
|
261
261
|
function processUrl(url) {
|
|
262
262
|
var _a, _b, _c, _d, _e, _f;
|
|
263
|
-
const matches = url.match(/^(https?:\/\/)?(([^:/?#]*)(?:(:[0-9]+))?)?([/]{0,1}[^?#]*)(\?[
|
|
263
|
+
const matches = url.match(/^(https?:\/\/)?(([^:/?#]*)(?:(:[0-9]+))?)?([/]{0,1}[^?#]*)(\?[^#?]*|)(#.*|)$/);
|
|
264
|
+
const protocol = (_a = matches == null ? void 0 : matches[1]) != null ? _a : "";
|
|
265
|
+
const domain = (_b = matches == null ? void 0 : matches[3]) != null ? _b : "";
|
|
266
|
+
const port = (_c = matches == null ? void 0 : matches[4]) != null ? _c : "";
|
|
267
|
+
const path = (_d = matches == null ? void 0 : matches[5].replace(/\/+$/g, "")) != null ? _d : "";
|
|
268
|
+
const query = (_e = matches == null ? void 0 : matches[6]) != null ? _e : "";
|
|
269
|
+
const fragment = (_f = matches == null ? void 0 : matches[7]) != null ? _f : "";
|
|
264
270
|
return {
|
|
265
|
-
url
|
|
266
|
-
protocol
|
|
267
|
-
domain
|
|
268
|
-
port
|
|
269
|
-
path
|
|
270
|
-
query
|
|
271
|
-
fragment
|
|
271
|
+
url: `${protocol}${domain}${port}${path}${query}${fragment}`,
|
|
272
|
+
protocol,
|
|
273
|
+
domain,
|
|
274
|
+
port,
|
|
275
|
+
path,
|
|
276
|
+
query,
|
|
277
|
+
fragment
|
|
272
278
|
};
|
|
273
279
|
}
|
|
274
280
|
|
|
@@ -328,6 +334,7 @@ function mergeQueryStrings(qs1, qs2) {
|
|
|
328
334
|
var _RedirectClient = class _RedirectClient extends ApiClient {
|
|
329
335
|
constructor(options) {
|
|
330
336
|
super(options);
|
|
337
|
+
// Get a single redirect by ID or project map id
|
|
331
338
|
this.getRedirect = async (options) => {
|
|
332
339
|
var _a;
|
|
333
340
|
const { projectId } = this.options;
|
|
@@ -335,12 +342,14 @@ var _RedirectClient = class _RedirectClient extends ApiClient {
|
|
|
335
342
|
const results = await this.apiClient(fetchUri);
|
|
336
343
|
return (_a = results.redirects) == null ? void 0 : _a[0];
|
|
337
344
|
};
|
|
345
|
+
// Get redirects by list of IDs, source URL, target URL, or search
|
|
338
346
|
this.getRedirects = async (options) => {
|
|
339
347
|
const { projectId } = this.options;
|
|
340
348
|
const fetchUri = this.createUrl("/api/v1/redirect", { ...options, projectId });
|
|
341
349
|
const results = await this.apiClient(fetchUri);
|
|
342
350
|
return results;
|
|
343
351
|
};
|
|
352
|
+
// Assemble a trie powered search structure, used to have instant resolution of redirects. Note, result set may be large.
|
|
344
353
|
this.getRedirectTrie = async (options) => {
|
|
345
354
|
var _a, _b;
|
|
346
355
|
const { projectId } = this.options;
|
|
@@ -432,6 +441,8 @@ var _RedirectClient = class _RedirectClient extends ApiClient {
|
|
|
432
441
|
const trie = await this.getRedirectTrie();
|
|
433
442
|
return (_b = _RedirectClient.processHops(sanitizedUrl, trie, true, options)) == null ? void 0 : _b[0];
|
|
434
443
|
};
|
|
444
|
+
// Caculate redirect matches based on an incoming URL with an option to use a trie storage structure to streamline future
|
|
445
|
+
// redirect resolutions. Note this may cause a large in memory load for large collections of redirect, off by default.
|
|
435
446
|
this.processUrlAllMatches = async (url, options, useTrie) => {
|
|
436
447
|
const sanitizedUrl = url.endsWith("/") ? url.replace(/\/+$/, "") : url;
|
|
437
448
|
if (!useTrie) {
|
|
@@ -464,6 +475,7 @@ var _RedirectClient = class _RedirectClient extends ApiClient {
|
|
|
464
475
|
}
|
|
465
476
|
}
|
|
466
477
|
}
|
|
478
|
+
// Get all redirects in Uniform 500 at a time.
|
|
467
479
|
async *getAllRedirects(orderBy = "updated_at desc") {
|
|
468
480
|
var _a, _b;
|
|
469
481
|
const { projectId } = this.options;
|
|
@@ -512,6 +524,8 @@ var _RedirectClient = class _RedirectClient extends ApiClient {
|
|
|
512
524
|
}
|
|
513
525
|
return await _RedirectClient.assemblingPromise;
|
|
514
526
|
}
|
|
527
|
+
// Find all redirects involved for the current URL, this is for the case where a redirect definition leads to
|
|
528
|
+
// another redirect. This also involves cycle busting error handling
|
|
515
529
|
static processHops(initialUrl, trie, bestMatch, options) {
|
|
516
530
|
const url = (options == null ? void 0 : options.reverse) ? initialUrl.replace(/\/:/, "/~~") : initialUrl;
|
|
517
531
|
const isCycle = (id, result) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uniformdev/redirect",
|
|
3
|
-
"version": "19.79.
|
|
3
|
+
"version": "19.79.1-alpha.13+608a273da",
|
|
4
4
|
"description": "Uniform redirect client",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -33,12 +33,12 @@
|
|
|
33
33
|
"/dist"
|
|
34
34
|
],
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@uniformdev/context": "19.79.
|
|
36
|
+
"@uniformdev/context": "19.79.1-alpha.13+608a273da",
|
|
37
37
|
"p-limit": "^3.1.0",
|
|
38
38
|
"rfdc": "^1.3.0"
|
|
39
39
|
},
|
|
40
40
|
"publishConfig": {
|
|
41
41
|
"access": "public"
|
|
42
42
|
},
|
|
43
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "608a273da87aa432f17b2c8ce15d747dadab0cd1"
|
|
44
44
|
}
|