mirror of
https://github.com/sern-handler/website
synced 2026-06-28 02:32:23 +00:00
24 lines
390 B
TypeScript
24 lines
390 B
TypeScript
export function stripLeadingSlash(path: string) {
|
|
if (!path.startsWith('/')) {
|
|
return path
|
|
}
|
|
|
|
return path.slice(1)
|
|
}
|
|
|
|
export function stripTrailingSlash(path: string) {
|
|
if (!path.endsWith('/')) {
|
|
return path
|
|
}
|
|
|
|
return path.slice(0, -1)
|
|
}
|
|
|
|
export function ensureTrailingSlash(path: string): string {
|
|
if (path.endsWith('/')) {
|
|
return path
|
|
}
|
|
|
|
return `${path}/`
|
|
}
|