Files
klz-cables.com/.pnpm-store/v10/files/5f/46fbc21d659687a9fe8ca52054b28ac4ed3784bc2748f31545ea285df3cde181d3921412ad2a8fbef841c4002db3972ed0027677ea528b474897763ce30f49
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

28 lines
779 B
Plaintext

import { IsSanctionedSimpleUnitIdentifier } from "./IsSanctionedSimpleUnitIdentifier.js";
/**
* This follows https://tc39.es/ecma402/#sec-case-sensitivity-and-case-mapping
* @param str string to convert
*/
function toLowerCase(str) {
return str.replace(/([A-Z])/g, (_, c) => c.toLowerCase());
}
/**
* https://tc39.es/ecma402/#sec-iswellformedunitidentifier
* @param unit
*/
export function IsWellFormedUnitIdentifier(unit) {
unit = toLowerCase(unit);
if (IsSanctionedSimpleUnitIdentifier(unit)) {
return true;
}
const units = unit.split("-per-");
if (units.length !== 2) {
return false;
}
const [numerator, denominator] = units;
if (!IsSanctionedSimpleUnitIdentifier(numerator) || !IsSanctionedSimpleUnitIdentifier(denominator)) {
return false;
}
return true;
}