simple-fs-server/util/util.ts

11 lines
274 B
TypeScript
Raw Normal View History

2023-01-05 18:18:07 +09:00
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;
}