@uniformdev/redirect 19.45.0 → 19.45.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/dist/index.d.mts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.esm.js +21 -12
- package/dist/index.js +21 -12
- package/dist/index.mjs +21 -12
- package/package.json +3 -3
package/dist/index.d.mts
CHANGED
|
@@ -137,6 +137,8 @@ interface paths {
|
|
|
137
137
|
ids?: string[];
|
|
138
138
|
/** Source url to attempt to find redirects for */
|
|
139
139
|
sourceUrl?: string;
|
|
140
|
+
/** Find redirects that could redirect to this url */
|
|
141
|
+
targetUrl?: string;
|
|
140
142
|
/** Id of the project map the source or target belongs to. */
|
|
141
143
|
projectMapId?: string;
|
|
142
144
|
/** Id of the project map node to find redirects for. */
|
|
@@ -389,7 +391,7 @@ type RedirectDataCache = {
|
|
|
389
391
|
preload?: boolean;
|
|
390
392
|
};
|
|
391
393
|
type RedirectClientGetRedirect = Pick<RedirectClientGetRequest, 'id' | 'projectMapId' | 'sourceProjectMapNodeId' | 'targetProjectMapNodeId'>;
|
|
392
|
-
type RedirectClientGetRedirects = Pick<RedirectClientGetRequest, 'ids' | 'limit' | 'offset' | 'orderBy' | 'search' | 'sourceUrl'>;
|
|
394
|
+
type RedirectClientGetRedirects = Pick<RedirectClientGetRequest, 'ids' | 'limit' | 'offset' | 'orderBy' | 'search' | 'sourceUrl' | 'targetUrl'>;
|
|
393
395
|
|
|
394
396
|
declare class WithMemoryCache extends RedirectClientCache<RedirectClientCacheOptions> {
|
|
395
397
|
private static refresher?;
|
package/dist/index.d.ts
CHANGED
|
@@ -137,6 +137,8 @@ interface paths {
|
|
|
137
137
|
ids?: string[];
|
|
138
138
|
/** Source url to attempt to find redirects for */
|
|
139
139
|
sourceUrl?: string;
|
|
140
|
+
/** Find redirects that could redirect to this url */
|
|
141
|
+
targetUrl?: string;
|
|
140
142
|
/** Id of the project map the source or target belongs to. */
|
|
141
143
|
projectMapId?: string;
|
|
142
144
|
/** Id of the project map node to find redirects for. */
|
|
@@ -389,7 +391,7 @@ type RedirectDataCache = {
|
|
|
389
391
|
preload?: boolean;
|
|
390
392
|
};
|
|
391
393
|
type RedirectClientGetRedirect = Pick<RedirectClientGetRequest, 'id' | 'projectMapId' | 'sourceProjectMapNodeId' | 'targetProjectMapNodeId'>;
|
|
392
|
-
type RedirectClientGetRedirects = Pick<RedirectClientGetRequest, 'ids' | 'limit' | 'offset' | 'orderBy' | 'search' | 'sourceUrl'>;
|
|
394
|
+
type RedirectClientGetRedirects = Pick<RedirectClientGetRequest, 'ids' | 'limit' | 'offset' | 'orderBy' | 'search' | 'sourceUrl' | 'targetUrl'>;
|
|
393
395
|
|
|
394
396
|
declare class WithMemoryCache extends RedirectClientCache<RedirectClientCacheOptions> {
|
|
395
397
|
private static refresher?;
|
package/dist/index.esm.js
CHANGED
|
@@ -360,40 +360,49 @@ var _RedirectClient = class _RedirectClient extends ApiClient {
|
|
|
360
360
|
};
|
|
361
361
|
this.processUrlBestMatch = async (url, options, useTrie) => {
|
|
362
362
|
var _a, _b;
|
|
363
|
+
const sanitizedUrl = url.endsWith("/") ? url.replace(/\/+$/, "") : url;
|
|
363
364
|
if (!useTrie) {
|
|
364
|
-
const redirects = await this.getRedirects(
|
|
365
|
-
|
|
365
|
+
const redirects = await this.getRedirects(
|
|
366
|
+
(options == null ? void 0 : options.reverse) ? { targetUrl: sanitizedUrl } : { sourceUrl: sanitizedUrl }
|
|
367
|
+
);
|
|
368
|
+
const processedUrl = processUrl(sanitizedUrl);
|
|
366
369
|
const redirect = (_a = redirects == null ? void 0 : redirects.redirects) == null ? void 0 : _a[0];
|
|
367
370
|
if (!redirect)
|
|
368
371
|
return void 0;
|
|
369
372
|
return _RedirectClient.processDefinitionToResults(
|
|
370
373
|
processedUrl,
|
|
371
374
|
redirect,
|
|
372
|
-
_RedirectClient.getSourceVariables(
|
|
375
|
+
_RedirectClient.getSourceVariables(
|
|
376
|
+
processedUrl.path,
|
|
377
|
+
processUrl((options == null ? void 0 : options.reverse) ? redirect.redirect.targetUrl : redirect.redirect.sourceUrl).path
|
|
378
|
+
),
|
|
373
379
|
options
|
|
374
380
|
);
|
|
375
381
|
}
|
|
376
382
|
const trie = await this.getRedirectTrie();
|
|
377
|
-
return (_b = _RedirectClient.processHops(
|
|
383
|
+
return (_b = _RedirectClient.processHops(sanitizedUrl, trie, true, options)) == null ? void 0 : _b[0];
|
|
378
384
|
};
|
|
379
385
|
this.processUrlAllMatches = async (url, options, useTrie) => {
|
|
386
|
+
const sanitizedUrl = url.endsWith("/") ? url.replace(/\/+$/, "") : url;
|
|
380
387
|
if (!useTrie) {
|
|
381
|
-
const redirects = await this.getRedirects(
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
388
|
+
const redirects = await this.getRedirects(
|
|
389
|
+
(options == null ? void 0 : options.reverse) ? { targetUrl: sanitizedUrl } : { sourceUrl: sanitizedUrl }
|
|
390
|
+
);
|
|
391
|
+
const processedUrl = processUrl(sanitizedUrl);
|
|
392
|
+
return redirects.redirects.filter((redirect) => redirect.redirect).map((redirect) => {
|
|
393
|
+
return _RedirectClient.processDefinitionToResults(
|
|
385
394
|
processedUrl,
|
|
386
395
|
redirect,
|
|
387
396
|
_RedirectClient.getSourceVariables(
|
|
388
397
|
processedUrl.path,
|
|
389
|
-
processUrl(redirect.redirect.sourceUrl).path
|
|
398
|
+
processUrl((options == null ? void 0 : options.reverse) ? redirect.redirect.targetUrl : redirect.redirect.sourceUrl).path
|
|
390
399
|
),
|
|
391
400
|
options
|
|
392
|
-
)
|
|
393
|
-
);
|
|
401
|
+
);
|
|
402
|
+
});
|
|
394
403
|
}
|
|
395
404
|
const trie = await this.getRedirectTrie();
|
|
396
|
-
return _RedirectClient.processHops(
|
|
405
|
+
return _RedirectClient.processHops(sanitizedUrl, trie, false, options);
|
|
397
406
|
};
|
|
398
407
|
if (options.dataCache && options.dataCache.options.prePopulate) {
|
|
399
408
|
if (!options.dataCache.get(options.projectId)) {
|
package/dist/index.js
CHANGED
|
@@ -698,40 +698,49 @@ var _RedirectClient = class _RedirectClient extends import_api.ApiClient {
|
|
|
698
698
|
};
|
|
699
699
|
this.processUrlBestMatch = async (url, options, useTrie) => {
|
|
700
700
|
var _a, _b;
|
|
701
|
+
const sanitizedUrl = url.endsWith("/") ? url.replace(/\/+$/, "") : url;
|
|
701
702
|
if (!useTrie) {
|
|
702
|
-
const redirects = await this.getRedirects(
|
|
703
|
-
|
|
703
|
+
const redirects = await this.getRedirects(
|
|
704
|
+
(options == null ? void 0 : options.reverse) ? { targetUrl: sanitizedUrl } : { sourceUrl: sanitizedUrl }
|
|
705
|
+
);
|
|
706
|
+
const processedUrl = processUrl(sanitizedUrl);
|
|
704
707
|
const redirect = (_a = redirects == null ? void 0 : redirects.redirects) == null ? void 0 : _a[0];
|
|
705
708
|
if (!redirect)
|
|
706
709
|
return void 0;
|
|
707
710
|
return _RedirectClient.processDefinitionToResults(
|
|
708
711
|
processedUrl,
|
|
709
712
|
redirect,
|
|
710
|
-
_RedirectClient.getSourceVariables(
|
|
713
|
+
_RedirectClient.getSourceVariables(
|
|
714
|
+
processedUrl.path,
|
|
715
|
+
processUrl((options == null ? void 0 : options.reverse) ? redirect.redirect.targetUrl : redirect.redirect.sourceUrl).path
|
|
716
|
+
),
|
|
711
717
|
options
|
|
712
718
|
);
|
|
713
719
|
}
|
|
714
720
|
const trie = await this.getRedirectTrie();
|
|
715
|
-
return (_b = _RedirectClient.processHops(
|
|
721
|
+
return (_b = _RedirectClient.processHops(sanitizedUrl, trie, true, options)) == null ? void 0 : _b[0];
|
|
716
722
|
};
|
|
717
723
|
this.processUrlAllMatches = async (url, options, useTrie) => {
|
|
724
|
+
const sanitizedUrl = url.endsWith("/") ? url.replace(/\/+$/, "") : url;
|
|
718
725
|
if (!useTrie) {
|
|
719
|
-
const redirects = await this.getRedirects(
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
726
|
+
const redirects = await this.getRedirects(
|
|
727
|
+
(options == null ? void 0 : options.reverse) ? { targetUrl: sanitizedUrl } : { sourceUrl: sanitizedUrl }
|
|
728
|
+
);
|
|
729
|
+
const processedUrl = processUrl(sanitizedUrl);
|
|
730
|
+
return redirects.redirects.filter((redirect) => redirect.redirect).map((redirect) => {
|
|
731
|
+
return _RedirectClient.processDefinitionToResults(
|
|
723
732
|
processedUrl,
|
|
724
733
|
redirect,
|
|
725
734
|
_RedirectClient.getSourceVariables(
|
|
726
735
|
processedUrl.path,
|
|
727
|
-
processUrl(redirect.redirect.sourceUrl).path
|
|
736
|
+
processUrl((options == null ? void 0 : options.reverse) ? redirect.redirect.targetUrl : redirect.redirect.sourceUrl).path
|
|
728
737
|
),
|
|
729
738
|
options
|
|
730
|
-
)
|
|
731
|
-
);
|
|
739
|
+
);
|
|
740
|
+
});
|
|
732
741
|
}
|
|
733
742
|
const trie = await this.getRedirectTrie();
|
|
734
|
-
return _RedirectClient.processHops(
|
|
743
|
+
return _RedirectClient.processHops(sanitizedUrl, trie, false, options);
|
|
735
744
|
};
|
|
736
745
|
if (options.dataCache && options.dataCache.options.prePopulate) {
|
|
737
746
|
if (!options.dataCache.get(options.projectId)) {
|
package/dist/index.mjs
CHANGED
|
@@ -360,40 +360,49 @@ var _RedirectClient = class _RedirectClient extends ApiClient {
|
|
|
360
360
|
};
|
|
361
361
|
this.processUrlBestMatch = async (url, options, useTrie) => {
|
|
362
362
|
var _a, _b;
|
|
363
|
+
const sanitizedUrl = url.endsWith("/") ? url.replace(/\/+$/, "") : url;
|
|
363
364
|
if (!useTrie) {
|
|
364
|
-
const redirects = await this.getRedirects(
|
|
365
|
-
|
|
365
|
+
const redirects = await this.getRedirects(
|
|
366
|
+
(options == null ? void 0 : options.reverse) ? { targetUrl: sanitizedUrl } : { sourceUrl: sanitizedUrl }
|
|
367
|
+
);
|
|
368
|
+
const processedUrl = processUrl(sanitizedUrl);
|
|
366
369
|
const redirect = (_a = redirects == null ? void 0 : redirects.redirects) == null ? void 0 : _a[0];
|
|
367
370
|
if (!redirect)
|
|
368
371
|
return void 0;
|
|
369
372
|
return _RedirectClient.processDefinitionToResults(
|
|
370
373
|
processedUrl,
|
|
371
374
|
redirect,
|
|
372
|
-
_RedirectClient.getSourceVariables(
|
|
375
|
+
_RedirectClient.getSourceVariables(
|
|
376
|
+
processedUrl.path,
|
|
377
|
+
processUrl((options == null ? void 0 : options.reverse) ? redirect.redirect.targetUrl : redirect.redirect.sourceUrl).path
|
|
378
|
+
),
|
|
373
379
|
options
|
|
374
380
|
);
|
|
375
381
|
}
|
|
376
382
|
const trie = await this.getRedirectTrie();
|
|
377
|
-
return (_b = _RedirectClient.processHops(
|
|
383
|
+
return (_b = _RedirectClient.processHops(sanitizedUrl, trie, true, options)) == null ? void 0 : _b[0];
|
|
378
384
|
};
|
|
379
385
|
this.processUrlAllMatches = async (url, options, useTrie) => {
|
|
386
|
+
const sanitizedUrl = url.endsWith("/") ? url.replace(/\/+$/, "") : url;
|
|
380
387
|
if (!useTrie) {
|
|
381
|
-
const redirects = await this.getRedirects(
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
388
|
+
const redirects = await this.getRedirects(
|
|
389
|
+
(options == null ? void 0 : options.reverse) ? { targetUrl: sanitizedUrl } : { sourceUrl: sanitizedUrl }
|
|
390
|
+
);
|
|
391
|
+
const processedUrl = processUrl(sanitizedUrl);
|
|
392
|
+
return redirects.redirects.filter((redirect) => redirect.redirect).map((redirect) => {
|
|
393
|
+
return _RedirectClient.processDefinitionToResults(
|
|
385
394
|
processedUrl,
|
|
386
395
|
redirect,
|
|
387
396
|
_RedirectClient.getSourceVariables(
|
|
388
397
|
processedUrl.path,
|
|
389
|
-
processUrl(redirect.redirect.sourceUrl).path
|
|
398
|
+
processUrl((options == null ? void 0 : options.reverse) ? redirect.redirect.targetUrl : redirect.redirect.sourceUrl).path
|
|
390
399
|
),
|
|
391
400
|
options
|
|
392
|
-
)
|
|
393
|
-
);
|
|
401
|
+
);
|
|
402
|
+
});
|
|
394
403
|
}
|
|
395
404
|
const trie = await this.getRedirectTrie();
|
|
396
|
-
return _RedirectClient.processHops(
|
|
405
|
+
return _RedirectClient.processHops(sanitizedUrl, trie, false, options);
|
|
397
406
|
};
|
|
398
407
|
if (options.dataCache && options.dataCache.options.prePopulate) {
|
|
399
408
|
if (!options.dataCache.get(options.projectId)) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uniformdev/redirect",
|
|
3
|
-
"version": "19.45.
|
|
3
|
+
"version": "19.45.1",
|
|
4
4
|
"description": "Uniform redirect client",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -32,12 +32,12 @@
|
|
|
32
32
|
"/dist"
|
|
33
33
|
],
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@uniformdev/context": "19.45.
|
|
35
|
+
"@uniformdev/context": "19.45.1",
|
|
36
36
|
"p-limit": "^3.1.0",
|
|
37
37
|
"rfdc": "^1.3.0"
|
|
38
38
|
},
|
|
39
39
|
"publishConfig": {
|
|
40
40
|
"access": "public"
|
|
41
41
|
},
|
|
42
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "27d329b913db64152e9d49bcfa7dddf8b3b31bb6"
|
|
43
43
|
}
|