next
Version:
The React Framework
10 lines (9 loc) • 356 B
TypeScript
/**
* Removes the trailing slash for a given route or page path. Examples:
* - `/foo/bar/` -> `/foo/bar`
* - `/foo/bar` -> `/foo/bar`
*
* Uses charCodeAt (47 === '/') instead of regex to avoid the overhead of
* compiling and executing a RegExp on every call (~3-5x faster).
*/
export declare function removeTrailingSlash(route: string): string;