You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
14 lines
416 B
TypeScript
14 lines
416 B
TypeScript
const FS_PREFIX = `/@fs/`;
|
|
const IS_WINDOWS = process.platform === 'win32';
|
|
const queryRE = /\?.*$/s;
|
|
const hashRE = /#.*$/s;
|
|
|
|
export function idToFile(id: string): string {
|
|
// strip /@fs/ but keep leading / on non-windows
|
|
if (id.startsWith(FS_PREFIX)) {
|
|
id = id = id.slice(IS_WINDOWS ? FS_PREFIX.length : FS_PREFIX.length - 1);
|
|
}
|
|
// strip query and hash
|
|
return id.replace(hashRE, '').replace(queryRE, '');
|
|
}
|