summaryrefslogtreecommitdiff
path: root/smoke/docs-main/src/util.ts
diff options
context:
space:
mode:
Diffstat (limited to 'smoke/docs-main/src/util.ts')
-rw-r--r--smoke/docs-main/src/util.ts14
1 files changed, 14 insertions, 0 deletions
diff --git a/smoke/docs-main/src/util.ts b/smoke/docs-main/src/util.ts
new file mode 100644
index 000000000..c20b0713e
--- /dev/null
+++ b/smoke/docs-main/src/util.ts
@@ -0,0 +1,14 @@
+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(/[/\\]+$/, '');
+}