Files
klz-cables.com/.pnpm-store/v10/files/17/7a9edcf2672762b0f2b8faf9e015be5ff9d36883a7937181eb3e551169a15369920d26a6ee857adef5ef9b47a9ad3f3a6eedcc5a2ee2d5f1ef535197361f4c
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

29 lines
1.0 KiB
Plaintext

/**
* Sanitize empty strings from the query, e.g. `?preset=`
* This is how we determine whether to clear user preferences for certain params
* Once cleared, they are no longer needed in the URL
*/export const sanitizeQuery = toSanitize => {
const sanitized = {
...toSanitize
};
Object.entries(sanitized).forEach(([key, value]) => {
if (key === 'columns' && (value === '[]' || Array.isArray(sanitized[key]) && sanitized[key].length === 0)) {
delete sanitized[key];
}
if (key === 'where' && typeof value === 'object' && value !== null && !Object.keys(value).length) {
delete sanitized[key];
}
if ((key === 'limit' || key === 'page') && typeof value === 'string') {
const parsed = parseInt(value, 10);
sanitized[key] = Number.isNaN(parsed) ? undefined : parsed;
}
if (key === 'page' && value === 0) {
delete sanitized[key];
}
if (value === '') {
delete sanitized[key];
}
});
return sanitized;
};
//# sourceMappingURL=sanitizeQuery.js.map