Files
klz-cables.com/.pnpm-store/v10/files/0f/0aa31e563aaa233fc85bf00bdad0c25702b9b820cdb52ef9a37d1e10d3fd3aab1cbc288e4be5761efbdd1487654e1ce4f668c850a8aa1f17a24ac2b7fd0503
Marc Mintel 5397309103
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
fix(products): fix breadcrumbs and product filtering (backport from main)
2026-02-24 16:04:21 +01:00

33 lines
1.3 KiB
Plaintext

export const isURLAllowed = (url, allowList)=>{
try {
const parsedUrl = new URL(url);
return allowList.some((allowItem)=>{
return Object.entries(allowItem).every(([key, value])=>{
// Skip undefined or null values
if (!value) {
return true;
}
// Compare protocol with colon
if (key === 'protocol') {
return typeof value === 'string' && parsedUrl.protocol === `${value}:`;
}
if (key === 'pathname') {
// Convert wildcards to a regex
const regexPattern = value.replace(/\*\*/g, '.*') // Match any path
.replace(/\*/g, '[^/]*') // Match any part of a path segment
.replace(/\/$/, '(/)?') // Allow optional trailing slash
;
const regex = new RegExp(`^${regexPattern}$`);
return regex.test(parsedUrl.pathname);
}
// Default comparison for all other properties (hostname, port, search)
return parsedUrl[key] === value;
});
});
} catch {
return false // If the URL is invalid, deny by default
;
}
};
//# sourceMappingURL=isURLAllowed.js.map