15736: "add-session" route, support tokens received from other clusters
[arvados-workbench2.git] / src / common / url.ts
index 1824f26a942426c29f544f9d77decd4ce8b58002..9789b65effb6b47d6ed14c0589cb39b2b032c2a4 100644 (file)
@@ -4,3 +4,12 @@ export function getUrlParameter(search: string, name: string) {
     const results = regex.exec(search);
     return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' '));
 }
+
+export function normalizeURLPath(url: string) {
+    const u = new URL(url);
+    u.pathname = u.pathname.replace(/\/\//, '/');
+    if (u.pathname[u.pathname.length - 1] === '/') {
+        u.pathname = u.pathname.substr(0, u.pathname.length - 1);
+    }
+    return u.toString();
+}