@uniformdev/redirect
Advanced tools
Comparing version 19.38.3-alpha.70 to 19.38.3-alpha.78
@@ -701,5 +701,8 @@ "use strict"; | ||
var _a, _b; | ||
const sanitizedUrl = url.endsWith("/") ? url.replace(/\/+$/, "") : url; | ||
if (!useTrie) { | ||
const redirects = await this.getRedirects({ sourceUrl: url }); | ||
const processedUrl = processUrl(url); | ||
const redirects = await this.getRedirects( | ||
(options == null ? void 0 : options.reverse) ? { targetUrl: sanitizedUrl } : { sourceUrl: sanitizedUrl } | ||
); | ||
const processedUrl = processUrl(sanitizedUrl); | ||
const redirect = (_a = redirects == null ? void 0 : redirects.redirects) == null ? void 0 : _a[0]; | ||
@@ -711,3 +714,6 @@ if (!redirect) | ||
redirect, | ||
_RedirectClient.getSourceVariables(processedUrl.path, processUrl(redirect.redirect.sourceUrl).path), | ||
_RedirectClient.getSourceVariables( | ||
processedUrl.path, | ||
processUrl((options == null ? void 0 : options.reverse) ? redirect.redirect.targetUrl : redirect.redirect.sourceUrl).path | ||
), | ||
options | ||
@@ -717,10 +723,13 @@ ); | ||
const trie = await this.getRedirectTrie(); | ||
return (_b = _RedirectClient.processHops(url, trie, true, options)) == null ? void 0 : _b[0]; | ||
return (_b = _RedirectClient.processHops(sanitizedUrl, trie, true, options)) == null ? void 0 : _b[0]; | ||
}; | ||
this.processUrlAllMatches = async (url, options, useTrie) => { | ||
const sanitizedUrl = url.endsWith("/") ? url.replace(/\/+$/, "") : url; | ||
if (!useTrie) { | ||
const redirects = await this.getRedirects({ sourceUrl: url }); | ||
const processedUrl = processUrl(url); | ||
return redirects.redirects.filter((redirect) => redirect.redirect).map( | ||
(redirect) => _RedirectClient.processDefinitionToResults( | ||
const redirects = await this.getRedirects( | ||
(options == null ? void 0 : options.reverse) ? { targetUrl: sanitizedUrl } : { sourceUrl: sanitizedUrl } | ||
); | ||
const processedUrl = processUrl(sanitizedUrl); | ||
return redirects.redirects.filter((redirect) => redirect.redirect).map((redirect) => { | ||
return _RedirectClient.processDefinitionToResults( | ||
processedUrl, | ||
@@ -730,10 +739,10 @@ redirect, | ||
processedUrl.path, | ||
processUrl(redirect.redirect.sourceUrl).path | ||
processUrl((options == null ? void 0 : options.reverse) ? redirect.redirect.targetUrl : redirect.redirect.sourceUrl).path | ||
), | ||
options | ||
) | ||
); | ||
); | ||
}); | ||
} | ||
const trie = await this.getRedirectTrie(); | ||
return _RedirectClient.processHops(url, trie, false, options); | ||
return _RedirectClient.processHops(sanitizedUrl, trie, false, options); | ||
}; | ||
@@ -740,0 +749,0 @@ if (options.dataCache && options.dataCache.options.prePopulate) { |
@@ -140,2 +140,4 @@ import { ClientOptions, ApiClient } from '@uniformdev/context/api'; | ||
sourceUrl?: string; | ||
/** Find redirects that could redirect to this url */ | ||
targetUrl?: string; | ||
/** Id of the project map the source or target belongs to. */ | ||
@@ -393,3 +395,3 @@ projectMapId?: string; | ||
type RedirectClientGetRedirect = Pick<RedirectClientGetRequest, 'id' | 'projectMapId' | 'sourceProjectMapNodeId' | 'targetProjectMapNodeId'>; | ||
type RedirectClientGetRedirects = Pick<RedirectClientGetRequest, 'ids' | 'limit' | 'offset' | 'orderBy' | 'search' | 'sourceUrl'>; | ||
type RedirectClientGetRedirects = Pick<RedirectClientGetRequest, 'ids' | 'limit' | 'offset' | 'orderBy' | 'search' | 'sourceUrl' | 'targetUrl'>; | ||
@@ -396,0 +398,0 @@ declare class WithMemoryCache extends RedirectClientCache<RedirectClientCacheOptions> { |
@@ -363,5 +363,8 @@ import "./chunk-TLYAXJ7N.mjs"; | ||
var _a, _b; | ||
const sanitizedUrl = url.endsWith("/") ? url.replace(/\/+$/, "") : url; | ||
if (!useTrie) { | ||
const redirects = await this.getRedirects({ sourceUrl: url }); | ||
const processedUrl = processUrl(url); | ||
const redirects = await this.getRedirects( | ||
(options == null ? void 0 : options.reverse) ? { targetUrl: sanitizedUrl } : { sourceUrl: sanitizedUrl } | ||
); | ||
const processedUrl = processUrl(sanitizedUrl); | ||
const redirect = (_a = redirects == null ? void 0 : redirects.redirects) == null ? void 0 : _a[0]; | ||
@@ -373,3 +376,6 @@ if (!redirect) | ||
redirect, | ||
_RedirectClient.getSourceVariables(processedUrl.path, processUrl(redirect.redirect.sourceUrl).path), | ||
_RedirectClient.getSourceVariables( | ||
processedUrl.path, | ||
processUrl((options == null ? void 0 : options.reverse) ? redirect.redirect.targetUrl : redirect.redirect.sourceUrl).path | ||
), | ||
options | ||
@@ -379,10 +385,13 @@ ); | ||
const trie = await this.getRedirectTrie(); | ||
return (_b = _RedirectClient.processHops(url, trie, true, options)) == null ? void 0 : _b[0]; | ||
return (_b = _RedirectClient.processHops(sanitizedUrl, trie, true, options)) == null ? void 0 : _b[0]; | ||
}; | ||
this.processUrlAllMatches = async (url, options, useTrie) => { | ||
const sanitizedUrl = url.endsWith("/") ? url.replace(/\/+$/, "") : url; | ||
if (!useTrie) { | ||
const redirects = await this.getRedirects({ sourceUrl: url }); | ||
const processedUrl = processUrl(url); | ||
return redirects.redirects.filter((redirect) => redirect.redirect).map( | ||
(redirect) => _RedirectClient.processDefinitionToResults( | ||
const redirects = await this.getRedirects( | ||
(options == null ? void 0 : options.reverse) ? { targetUrl: sanitizedUrl } : { sourceUrl: sanitizedUrl } | ||
); | ||
const processedUrl = processUrl(sanitizedUrl); | ||
return redirects.redirects.filter((redirect) => redirect.redirect).map((redirect) => { | ||
return _RedirectClient.processDefinitionToResults( | ||
processedUrl, | ||
@@ -392,10 +401,10 @@ redirect, | ||
processedUrl.path, | ||
processUrl(redirect.redirect.sourceUrl).path | ||
processUrl((options == null ? void 0 : options.reverse) ? redirect.redirect.targetUrl : redirect.redirect.sourceUrl).path | ||
), | ||
options | ||
) | ||
); | ||
); | ||
}); | ||
} | ||
const trie = await this.getRedirectTrie(); | ||
return _RedirectClient.processHops(url, trie, false, options); | ||
return _RedirectClient.processHops(sanitizedUrl, trie, false, options); | ||
}; | ||
@@ -402,0 +411,0 @@ if (options.dataCache && options.dataCache.options.prePopulate) { |
@@ -701,5 +701,8 @@ "use strict"; | ||
var _a, _b; | ||
const sanitizedUrl = url.endsWith("/") ? url.replace(/\/+$/, "") : url; | ||
if (!useTrie) { | ||
const redirects = await this.getRedirects({ sourceUrl: url }); | ||
const processedUrl = processUrl(url); | ||
const redirects = await this.getRedirects( | ||
(options == null ? void 0 : options.reverse) ? { targetUrl: sanitizedUrl } : { sourceUrl: sanitizedUrl } | ||
); | ||
const processedUrl = processUrl(sanitizedUrl); | ||
const redirect = (_a = redirects == null ? void 0 : redirects.redirects) == null ? void 0 : _a[0]; | ||
@@ -711,3 +714,6 @@ if (!redirect) | ||
redirect, | ||
_RedirectClient.getSourceVariables(processedUrl.path, processUrl(redirect.redirect.sourceUrl).path), | ||
_RedirectClient.getSourceVariables( | ||
processedUrl.path, | ||
processUrl((options == null ? void 0 : options.reverse) ? redirect.redirect.targetUrl : redirect.redirect.sourceUrl).path | ||
), | ||
options | ||
@@ -717,10 +723,13 @@ ); | ||
const trie = await this.getRedirectTrie(); | ||
return (_b = _RedirectClient.processHops(url, trie, true, options)) == null ? void 0 : _b[0]; | ||
return (_b = _RedirectClient.processHops(sanitizedUrl, trie, true, options)) == null ? void 0 : _b[0]; | ||
}; | ||
this.processUrlAllMatches = async (url, options, useTrie) => { | ||
const sanitizedUrl = url.endsWith("/") ? url.replace(/\/+$/, "") : url; | ||
if (!useTrie) { | ||
const redirects = await this.getRedirects({ sourceUrl: url }); | ||
const processedUrl = processUrl(url); | ||
return redirects.redirects.filter((redirect) => redirect.redirect).map( | ||
(redirect) => _RedirectClient.processDefinitionToResults( | ||
const redirects = await this.getRedirects( | ||
(options == null ? void 0 : options.reverse) ? { targetUrl: sanitizedUrl } : { sourceUrl: sanitizedUrl } | ||
); | ||
const processedUrl = processUrl(sanitizedUrl); | ||
return redirects.redirects.filter((redirect) => redirect.redirect).map((redirect) => { | ||
return _RedirectClient.processDefinitionToResults( | ||
processedUrl, | ||
@@ -730,10 +739,10 @@ redirect, | ||
processedUrl.path, | ||
processUrl(redirect.redirect.sourceUrl).path | ||
processUrl((options == null ? void 0 : options.reverse) ? redirect.redirect.targetUrl : redirect.redirect.sourceUrl).path | ||
), | ||
options | ||
) | ||
); | ||
); | ||
}); | ||
} | ||
const trie = await this.getRedirectTrie(); | ||
return _RedirectClient.processHops(url, trie, false, options); | ||
return _RedirectClient.processHops(sanitizedUrl, trie, false, options); | ||
}; | ||
@@ -740,0 +749,0 @@ if (options.dataCache && options.dataCache.options.prePopulate) { |
{ | ||
"name": "@uniformdev/redirect", | ||
"version": "19.38.3-alpha.70+55e5a8fe1", | ||
"version": "19.38.3-alpha.78+5c9892bf1", | ||
"description": "Uniform redirect client", | ||
@@ -35,3 +35,3 @@ "license": "SEE LICENSE IN LICENSE.txt", | ||
"dependencies": { | ||
"@uniformdev/context": "19.38.3-alpha.70+55e5a8fe1", | ||
"@uniformdev/context": "19.38.3-alpha.78+5c9892bf1", | ||
"p-limit": "^3.1.0", | ||
@@ -43,3 +43,3 @@ "rfdc": "^1.3.0" | ||
}, | ||
"gitHead": "55e5a8fe1d80971a93ea31d3a50cec72e71be70a" | ||
"gitHead": "5c9892bf101584d351d06b65e1658a1237594cfb" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
180598
4226