silverwolf-x's picture
download
raw
558 Bytes
/**
* This transforms a URL pathname into a route. It removes any trailing slashes
* and the `/index` suffix.
*
* @param pathname - The URL path that needs to be optimized.
* @returns - The route
*
* @example
* // returns '/example'
* toRoute('/example/index/');
*
* @example
* // returns '/example'
* toRoute('/example/');
*
* @example
* // returns '/'
* toRoute('/index/');
*
* @example
* // returns '/'
* toRoute('/');
*/
export function toRoute(pathname: string): string {
return pathname.replace(/(?:\/index)?\/?$/, '') || '/'
}

Xet Storage Details

Size:
558 Bytes
·
Xet hash:
b0add5650c0a4863c343eef35660c27db945d4073da46882e8b804a0308128b5

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.