11 lines
274 B
TypeScript
11 lines
274 B
TypeScript
|
export function removePrefixFromPathname(pathname: string, prefix: string): string {
|
||
|
let ret = pathname;
|
||
|
ret = ret.slice(prefix.length);
|
||
|
if (ret.startsWith("/")) {
|
||
|
ret = ret.slice(1);
|
||
|
}
|
||
|
if (ret === "") {
|
||
|
ret = ".";
|
||
|
}
|
||
|
return ret;
|
||
|
}
|