NeahNew/node_modules/next/dist/esm/build/static-paths/utils.js
2025-05-03 14:17:46 +02:00

25 lines
708 B
JavaScript

/**
* Encodes a parameter value using the provided encoder.
*
* @param value - The value to encode.
* @param encoder - The encoder to use.
* @returns The encoded value.
*/ export function encodeParam(value, encoder) {
let replaceValue;
if (Array.isArray(value)) {
replaceValue = value.map(encoder).join('/');
} else {
replaceValue = encoder(value);
}
return replaceValue;
}
/**
* Normalizes a pathname to a consistent format.
*
* @param pathname - The pathname to normalize.
* @returns The normalized pathname.
*/ export function normalizePathname(pathname) {
return pathname.replace(/\\/g, '/').replace(/(?!^)\/$/, '');
}
//# sourceMappingURL=utils.js.map