Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@uniformdev/redirect

Package Overview
Dependencies
Maintainers
10
Versions
464
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@uniformdev/redirect - npm Package Compare versions

Comparing version 19.37.1 to 19.38.2

70

./dist/index.js

@@ -496,7 +496,6 @@ "use strict";

const getVariables = () => {
return wildcards.map((wildcard) => {
if (wildcard.active)
return { key: wildcard.name, value: segments[wildcard.start] };
return void 0;
}).filter((wildcard) => Boolean(wildcard));
return wildcards.filter((wildcard) => Boolean(wildcard) && wildcard.active).reduce((variables, wildcard) => {
variables[wildcard.name] = segments[wildcard.start];
return variables;
}, new Object());
};

@@ -533,5 +532,7 @@ const getPropsStartingWithColon = (obj) => {

cur["*"][dataProp].forEach((splat) => {
const vars = getVariables();
vars[":splat"] = segments.slice(i).join("/");
splats.push({
data: splat,
variables: [...getVariables(), { key: ":splat", value: segments.slice(i).join("/") }]
variables: vars
});

@@ -651,3 +652,2 @@ });

sourceRetainQuerystring,
stopExecutingAfter,
targetMergeQuerystring,

@@ -672,3 +672,2 @@ targetPreserveIncomingDomain,

sourceRetainQuerystring,
stopExecutingAfter,
targetMergeQuerystring,

@@ -693,8 +692,34 @@ targetPreserveIncomingDomain,

};
this.processUrlBestMatch = async (url, options) => {
this.processUrlBestMatch = async (url, options, useTrie) => {
var _a;
if (!useTrie) {
const redirects = await this.getRedirects({ sourceUrl: url });
const processedUrl = processUrl(url);
const redirect = redirects.redirects[0];
return _RedirectClient.processDefinitionToResults(
processedUrl,
redirect,
_RedirectClient.getSourceVariables(processedUrl.path, processUrl(redirect.redirect.sourceUrl).path),
options
);
}
const trie = await this.getRedirectTrie();
return (_a = _RedirectClient.processHops(url, trie, true, options)) == null ? void 0 : _a[0];
};
this.processUrlAllMatches = async (url, options) => {
this.processUrlAllMatches = async (url, options, useTrie) => {
if (!useTrie) {
const redirects = await this.getRedirects({ sourceUrl: url });
const processedUrl = processUrl(url);
return redirects.redirects.filter((redirect) => redirect.redirect).map(
(redirect) => _RedirectClient.processDefinitionToResults(
processedUrl,
redirect,
_RedirectClient.getSourceVariables(
processedUrl.path,
processUrl(redirect.redirect.sourceUrl).path
),
options
)
);
}
const trie = await this.getRedirectTrie();

@@ -762,6 +787,5 @@ return _RedirectClient.processHops(url, trie, false, options);

static processHops(initialUrl, trie, bestMatch, options) {
var _a;
const url = (options == null ? void 0 : options.reverse) ? initialUrl.replace(/\/:/, "/~~") : initialUrl;
const isCycle = (id, result) => {
var _a2;
var _a;
if (!id || !result.lastHop)

@@ -773,3 +797,3 @@ return false;

const cur = cycleStack.pop();
const redirect = (_a2 = cur == null ? void 0 : cur.definition) == null ? void 0 : _a2.redirect;
const redirect = (_a = cur == null ? void 0 : cur.definition) == null ? void 0 : _a.redirect;
if (!(redirect == null ? void 0 : redirect.id))

@@ -792,7 +816,6 @@ continue;

continue;
const redirect = (_a = result.definition) == null ? void 0 : _a.redirect;
const hop = (redirect == null ? void 0 : redirect.stopExecutingAfter) ? [] : this.processHop(result == null ? void 0 : result.url, trie, bestMatch, options).filter(
const hop = this.processHop(result == null ? void 0 : result.url, trie, bestMatch, options).filter(
(h) => {
var _a2, _b;
return ((_a2 = h.definition) == null ? void 0 : _a2.redirect.id) && !isCycle((_b = h.definition) == null ? void 0 : _b.redirect.id, result);
var _a, _b;
return ((_a = h.definition) == null ? void 0 : _a.redirect.id) && !isCycle((_b = h.definition) == null ? void 0 : _b.redirect.id, result);
}

@@ -838,4 +861,4 @@ );

definition,
label: (options == null ? void 0 : options.label) ? variables.reduce((cur, o) => {
return cur.replace(o.key, `<em>${o.value}</em>`);
label: (options == null ? void 0 : options.label) ? Object.keys(variables).reduce((cur, o) => {
return cur.replace(variables[o], `<em>${variables[o]}</em>`);
}, finalUrl) : void 0

@@ -870,5 +893,8 @@ };

}
const protocol = redirectDefinition.targetPreserveIncomingProtocol ? processedUrl.protocol : processedTarget.protocol;
const domain = redirectDefinition.targetPreserveIncomingDomain ? processedUrl.domain : processedTarget.domain;
const port = redirectDefinition.targetPreserveIncomingDomain ? processedUrl.port : processedTarget.port;
let protocol = redirectDefinition.targetPreserveIncomingProtocol || processedTarget.protocol === "" ? processedUrl.protocol : processedTarget.protocol;
const domain = protocol !== "" ? redirectDefinition.targetPreserveIncomingDomain || processedTarget.domain === "" ? processedUrl.domain : processedTarget.domain : "";
if (domain === "" && protocol !== "") {
protocol = "";
}
const port = domain === "" ? "" : redirectDefinition.targetPreserveIncomingDomain || processedTarget.domain === "" ? processedUrl.port : processedTarget.port;
const query = redirectDefinition.sourceRetainQuerystring && redirectDefinition.targetMergeQuerystring ? this.mergeQueryStrings(processedUrl.query, processedTarget.query) : !redirectDefinition.targetMergeQuerystring && redirectDefinition.sourceRetainQuerystring ? processedUrl.query : processedTarget.query;

@@ -875,0 +901,0 @@ const fragment = redirectDefinition.sourceRetainQuerystring && redirectDefinition.targetMergeQuerystring ? this.mergeQueryStrings(processedUrl.fragment, processedTarget.fragment) : !redirectDefinition.targetMergeQuerystring && redirectDefinition.sourceRetainQuerystring ? processedUrl.fragment : processedTarget.fragment;

@@ -6,5 +6,4 @@ import { ClientOptions, ApiClient } from '@uniformdev/context/api';

variables: {
key: string;
value: string;
}[];
[variable: string]: string;
};
}

@@ -81,3 +80,2 @@ declare class PathTrie<T> {

targetPreserveIncomingDomain?: boolean | undefined;
stopExecutingAfter?: boolean | undefined;
targetMergeQuerystring?: boolean | undefined;

@@ -102,4 +100,4 @@ labelAsSystem?: boolean | undefined;

static processUrlBestMatch: (url: string, trie: PathTrie<DirectionAwareRedirectDefinition>, options?: RedirectOptions) => Promise<RedirectResult | undefined>;
processUrlBestMatch: (url: string, options?: RedirectOptions) => Promise<RedirectResult | undefined>;
processUrlAllMatches: (url: string, options?: RedirectOptions) => Promise<RedirectResult[]>;
processUrlBestMatch: (url: string, options?: RedirectOptions, useTrie?: boolean) => Promise<RedirectResult | undefined>;
processUrlAllMatches: (url: string, options?: RedirectOptions, useTrie?: boolean) => Promise<RedirectResult[]>;
private static assembling;

@@ -317,4 +315,2 @@ private static assemblingPromise;

targetPreserveIncomingDomain?: boolean;
/** @description Stop running rules after this redirect rule gets executed. */
stopExecutingAfter?: boolean;
/** @description Merge incoming querystring with the querystring defined on the redirection target, taking the incoming querystring parameter where a merge is not possible. */

@@ -400,3 +396,3 @@ targetMergeQuerystring?: boolean;

type RedirectClientGetRedirect = Pick<RedirectClientGetRequest, 'id' | 'projectMapId' | 'sourceProjectMapNodeId' | 'targetProjectMapNodeId'>;
type RedirectClientGetRedirects = Pick<RedirectClientGetRequest, 'ids' | 'limit' | 'offset' | 'orderBy' | 'search'>;
type RedirectClientGetRedirects = Pick<RedirectClientGetRequest, 'ids' | 'limit' | 'offset' | 'orderBy' | 'search' | 'sourceUrl'>;

@@ -403,0 +399,0 @@ declare class WithMemoryCache extends RedirectClientCache<RedirectClientCacheOptions> {

@@ -169,7 +169,6 @@ import "./chunk-TLYAXJ7N.mjs";

const getVariables = () => {
return wildcards.map((wildcard) => {
if (wildcard.active)
return { key: wildcard.name, value: segments[wildcard.start] };
return void 0;
}).filter((wildcard) => Boolean(wildcard));
return wildcards.filter((wildcard) => Boolean(wildcard) && wildcard.active).reduce((variables, wildcard) => {
variables[wildcard.name] = segments[wildcard.start];
return variables;
}, new Object());
};

@@ -206,5 +205,7 @@ const getPropsStartingWithColon = (obj) => {

cur["*"][dataProp].forEach((splat) => {
const vars = getVariables();
vars[":splat"] = segments.slice(i).join("/");
splats.push({
data: splat,
variables: [...getVariables(), { key: ":splat", value: segments.slice(i).join("/") }]
variables: vars
});

@@ -324,3 +325,2 @@ });

sourceRetainQuerystring,
stopExecutingAfter,
targetMergeQuerystring,

@@ -345,3 +345,2 @@ targetPreserveIncomingDomain,

sourceRetainQuerystring,
stopExecutingAfter,
targetMergeQuerystring,

@@ -366,8 +365,34 @@ targetPreserveIncomingDomain,

};
this.processUrlBestMatch = async (url, options) => {
this.processUrlBestMatch = async (url, options, useTrie) => {
var _a;
if (!useTrie) {
const redirects = await this.getRedirects({ sourceUrl: url });
const processedUrl = processUrl(url);
const redirect = redirects.redirects[0];
return _RedirectClient.processDefinitionToResults(
processedUrl,
redirect,
_RedirectClient.getSourceVariables(processedUrl.path, processUrl(redirect.redirect.sourceUrl).path),
options
);
}
const trie = await this.getRedirectTrie();
return (_a = _RedirectClient.processHops(url, trie, true, options)) == null ? void 0 : _a[0];
};
this.processUrlAllMatches = async (url, options) => {
this.processUrlAllMatches = async (url, options, useTrie) => {
if (!useTrie) {
const redirects = await this.getRedirects({ sourceUrl: url });
const processedUrl = processUrl(url);
return redirects.redirects.filter((redirect) => redirect.redirect).map(
(redirect) => _RedirectClient.processDefinitionToResults(
processedUrl,
redirect,
_RedirectClient.getSourceVariables(
processedUrl.path,
processUrl(redirect.redirect.sourceUrl).path
),
options
)
);
}
const trie = await this.getRedirectTrie();

@@ -435,6 +460,5 @@ return _RedirectClient.processHops(url, trie, false, options);

static processHops(initialUrl, trie, bestMatch, options) {
var _a;
const url = (options == null ? void 0 : options.reverse) ? initialUrl.replace(/\/:/, "/~~") : initialUrl;
const isCycle = (id, result) => {
var _a2;
var _a;
if (!id || !result.lastHop)

@@ -446,3 +470,3 @@ return false;

const cur = cycleStack.pop();
const redirect = (_a2 = cur == null ? void 0 : cur.definition) == null ? void 0 : _a2.redirect;
const redirect = (_a = cur == null ? void 0 : cur.definition) == null ? void 0 : _a.redirect;
if (!(redirect == null ? void 0 : redirect.id))

@@ -465,7 +489,6 @@ continue;

continue;
const redirect = (_a = result.definition) == null ? void 0 : _a.redirect;
const hop = (redirect == null ? void 0 : redirect.stopExecutingAfter) ? [] : this.processHop(result == null ? void 0 : result.url, trie, bestMatch, options).filter(
const hop = this.processHop(result == null ? void 0 : result.url, trie, bestMatch, options).filter(
(h) => {
var _a2, _b;
return ((_a2 = h.definition) == null ? void 0 : _a2.redirect.id) && !isCycle((_b = h.definition) == null ? void 0 : _b.redirect.id, result);
var _a, _b;
return ((_a = h.definition) == null ? void 0 : _a.redirect.id) && !isCycle((_b = h.definition) == null ? void 0 : _b.redirect.id, result);
}

@@ -511,4 +534,4 @@ );

definition,
label: (options == null ? void 0 : options.label) ? variables.reduce((cur, o) => {
return cur.replace(o.key, `<em>${o.value}</em>`);
label: (options == null ? void 0 : options.label) ? Object.keys(variables).reduce((cur, o) => {
return cur.replace(variables[o], `<em>${variables[o]}</em>`);
}, finalUrl) : void 0

@@ -543,5 +566,8 @@ };

}
const protocol = redirectDefinition.targetPreserveIncomingProtocol ? processedUrl.protocol : processedTarget.protocol;
const domain = redirectDefinition.targetPreserveIncomingDomain ? processedUrl.domain : processedTarget.domain;
const port = redirectDefinition.targetPreserveIncomingDomain ? processedUrl.port : processedTarget.port;
let protocol = redirectDefinition.targetPreserveIncomingProtocol || processedTarget.protocol === "" ? processedUrl.protocol : processedTarget.protocol;
const domain = protocol !== "" ? redirectDefinition.targetPreserveIncomingDomain || processedTarget.domain === "" ? processedUrl.domain : processedTarget.domain : "";
if (domain === "" && protocol !== "") {
protocol = "";
}
const port = domain === "" ? "" : redirectDefinition.targetPreserveIncomingDomain || processedTarget.domain === "" ? processedUrl.port : processedTarget.port;
const query = redirectDefinition.sourceRetainQuerystring && redirectDefinition.targetMergeQuerystring ? this.mergeQueryStrings(processedUrl.query, processedTarget.query) : !redirectDefinition.targetMergeQuerystring && redirectDefinition.sourceRetainQuerystring ? processedUrl.query : processedTarget.query;

@@ -548,0 +574,0 @@ const fragment = redirectDefinition.sourceRetainQuerystring && redirectDefinition.targetMergeQuerystring ? this.mergeQueryStrings(processedUrl.fragment, processedTarget.fragment) : !redirectDefinition.targetMergeQuerystring && redirectDefinition.sourceRetainQuerystring ? processedUrl.fragment : processedTarget.fragment;

@@ -496,7 +496,6 @@ "use strict";

const getVariables = () => {
return wildcards.map((wildcard) => {
if (wildcard.active)
return { key: wildcard.name, value: segments[wildcard.start] };
return void 0;
}).filter((wildcard) => Boolean(wildcard));
return wildcards.filter((wildcard) => Boolean(wildcard) && wildcard.active).reduce((variables, wildcard) => {
variables[wildcard.name] = segments[wildcard.start];
return variables;
}, new Object());
};

@@ -533,5 +532,7 @@ const getPropsStartingWithColon = (obj) => {

cur["*"][dataProp].forEach((splat) => {
const vars = getVariables();
vars[":splat"] = segments.slice(i).join("/");
splats.push({
data: splat,
variables: [...getVariables(), { key: ":splat", value: segments.slice(i).join("/") }]
variables: vars
});

@@ -651,3 +652,2 @@ });

sourceRetainQuerystring,
stopExecutingAfter,
targetMergeQuerystring,

@@ -672,3 +672,2 @@ targetPreserveIncomingDomain,

sourceRetainQuerystring,
stopExecutingAfter,
targetMergeQuerystring,

@@ -693,8 +692,34 @@ targetPreserveIncomingDomain,

};
this.processUrlBestMatch = async (url, options) => {
this.processUrlBestMatch = async (url, options, useTrie) => {
var _a;
if (!useTrie) {
const redirects = await this.getRedirects({ sourceUrl: url });
const processedUrl = processUrl(url);
const redirect = redirects.redirects[0];
return _RedirectClient.processDefinitionToResults(
processedUrl,
redirect,
_RedirectClient.getSourceVariables(processedUrl.path, processUrl(redirect.redirect.sourceUrl).path),
options
);
}
const trie = await this.getRedirectTrie();
return (_a = _RedirectClient.processHops(url, trie, true, options)) == null ? void 0 : _a[0];
};
this.processUrlAllMatches = async (url, options) => {
this.processUrlAllMatches = async (url, options, useTrie) => {
if (!useTrie) {
const redirects = await this.getRedirects({ sourceUrl: url });
const processedUrl = processUrl(url);
return redirects.redirects.filter((redirect) => redirect.redirect).map(
(redirect) => _RedirectClient.processDefinitionToResults(
processedUrl,
redirect,
_RedirectClient.getSourceVariables(
processedUrl.path,
processUrl(redirect.redirect.sourceUrl).path
),
options
)
);
}
const trie = await this.getRedirectTrie();

@@ -762,6 +787,5 @@ return _RedirectClient.processHops(url, trie, false, options);

static processHops(initialUrl, trie, bestMatch, options) {
var _a;
const url = (options == null ? void 0 : options.reverse) ? initialUrl.replace(/\/:/, "/~~") : initialUrl;
const isCycle = (id, result) => {
var _a2;
var _a;
if (!id || !result.lastHop)

@@ -773,3 +797,3 @@ return false;

const cur = cycleStack.pop();
const redirect = (_a2 = cur == null ? void 0 : cur.definition) == null ? void 0 : _a2.redirect;
const redirect = (_a = cur == null ? void 0 : cur.definition) == null ? void 0 : _a.redirect;
if (!(redirect == null ? void 0 : redirect.id))

@@ -792,7 +816,6 @@ continue;

continue;
const redirect = (_a = result.definition) == null ? void 0 : _a.redirect;
const hop = (redirect == null ? void 0 : redirect.stopExecutingAfter) ? [] : this.processHop(result == null ? void 0 : result.url, trie, bestMatch, options).filter(
const hop = this.processHop(result == null ? void 0 : result.url, trie, bestMatch, options).filter(
(h) => {
var _a2, _b;
return ((_a2 = h.definition) == null ? void 0 : _a2.redirect.id) && !isCycle((_b = h.definition) == null ? void 0 : _b.redirect.id, result);
var _a, _b;
return ((_a = h.definition) == null ? void 0 : _a.redirect.id) && !isCycle((_b = h.definition) == null ? void 0 : _b.redirect.id, result);
}

@@ -838,4 +861,4 @@ );

definition,
label: (options == null ? void 0 : options.label) ? variables.reduce((cur, o) => {
return cur.replace(o.key, `<em>${o.value}</em>`);
label: (options == null ? void 0 : options.label) ? Object.keys(variables).reduce((cur, o) => {
return cur.replace(variables[o], `<em>${variables[o]}</em>`);
}, finalUrl) : void 0

@@ -870,5 +893,8 @@ };

}
const protocol = redirectDefinition.targetPreserveIncomingProtocol ? processedUrl.protocol : processedTarget.protocol;
const domain = redirectDefinition.targetPreserveIncomingDomain ? processedUrl.domain : processedTarget.domain;
const port = redirectDefinition.targetPreserveIncomingDomain ? processedUrl.port : processedTarget.port;
let protocol = redirectDefinition.targetPreserveIncomingProtocol || processedTarget.protocol === "" ? processedUrl.protocol : processedTarget.protocol;
const domain = protocol !== "" ? redirectDefinition.targetPreserveIncomingDomain || processedTarget.domain === "" ? processedUrl.domain : processedTarget.domain : "";
if (domain === "" && protocol !== "") {
protocol = "";
}
const port = domain === "" ? "" : redirectDefinition.targetPreserveIncomingDomain || processedTarget.domain === "" ? processedUrl.port : processedTarget.port;
const query = redirectDefinition.sourceRetainQuerystring && redirectDefinition.targetMergeQuerystring ? this.mergeQueryStrings(processedUrl.query, processedTarget.query) : !redirectDefinition.targetMergeQuerystring && redirectDefinition.sourceRetainQuerystring ? processedUrl.query : processedTarget.query;

@@ -875,0 +901,0 @@ const fragment = redirectDefinition.sourceRetainQuerystring && redirectDefinition.targetMergeQuerystring ? this.mergeQueryStrings(processedUrl.fragment, processedTarget.fragment) : !redirectDefinition.targetMergeQuerystring && redirectDefinition.sourceRetainQuerystring ? processedUrl.fragment : processedTarget.fragment;

{
"name": "@uniformdev/redirect",
"version": "19.37.1",
"version": "19.38.2",
"description": "Uniform redirect client",

@@ -35,3 +35,3 @@ "license": "SEE LICENSE IN LICENSE.txt",

"dependencies": {
"@uniformdev/context": "19.37.1",
"@uniformdev/context": "19.38.2",
"p-limit": "^3.1.0",

@@ -43,3 +43,3 @@ "rfdc": "^1.3.0"

},
"gitHead": "9de2a3f7515d658d07d7d1fb8ebf4805172e655c"
"gitHead": "b97fd17fd44e0f5bd3806e942b516cb2bd218096"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc