diff options
Diffstat (limited to '')
-rw-r--r-- | docs/src/util.ts | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/docs/src/util.ts b/docs/src/util.ts index 0ec91bce0..269373735 100644 --- a/docs/src/util.ts +++ b/docs/src/util.ts @@ -2,3 +2,13 @@ export function getLanguageFromURL(pathname: string) { const langCodeMatch = pathname.match(/\/([a-z]{2}-?[A-Z]{0,2})\//); return langCodeMatch ? langCodeMatch[1] : 'en'; } + +/** Remove \ and / from beginning of string */ +export function removeLeadingSlash(path: string) { + return path.replace(/^[/\\]+/, ''); +} + +/** Remove \ and / from end of string */ +export function removeTrailingSlash(path: string) { + return path.replace(/[/\\]+$/, ''); +} |