Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | 12x 12x 3x 9x 35x 508x | /**
* Shared utilities
*/
/**
* Normalizes a path by removing double slashes and ensuring consistent format
* Preserves the leading slash if present
*/
export function normalizePath(path: string): string {
const normalized = path.replace(/\/+/g, '/');
// If it ends with / and it's not just the root slash, remove it
if (normalized !== '/' && normalized.endsWith('/')) {
return normalized.slice(0, -1);
}
return normalized || '/';
}
/**
* Checks if a string is a valid HTTP method
*/
export function isHttpMethod(str: string): str is 'get' | 'post' | 'put' | 'patch' | 'delete' | 'head' | 'options' {
return ['get', 'post', 'put', 'patch', 'delete', 'head', 'options'].includes(str.toLowerCase());
}
/**
* Capitalizes the first letter of a string
*/
export function capitalize(str: string): string {
return str.charAt(0).toUpperCase() + str.slice(1);
}
|