17782: Removes the last linter warnings.
[arvados-workbench2.git] / src / common / url.ts
index 6223485eabee6908fa363ea94e7345c1c54d7822..6d66778ad3a681bb05598aba7484b49bbb7e8007 100644 (file)
@@ -3,7 +3,7 @@
 // SPDX-License-Identifier: AGPL-3.0
 
 export function getUrlParameter(search: string, name: string) {
-    const safeName = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]');
+    const safeName = name.replace(/[[]/, '\\[').replace(/[\]]/, '\\]');
     const regex = new RegExp('[\\?&]' + safeName + '=([^&#]*)');
     const results = regex.exec(search);
     return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' '));
@@ -18,9 +18,18 @@ export function normalizeURLPath(url: string) {
     return u.toString();
 }
 
-export const escapeHashIfRequired = (name: string, defaultTransformation?: Function) =>
-    name.indexOf('#') > -1 ?
-        encodeURIComponent(name) :
-        defaultTransformation ?
-            defaultTransformation(name) :
-            name;
\ No newline at end of file
+export const customEncodeURI = (path: string) => {
+    try {
+        return path.split('/').map(encodeURIComponent).join('/');
+    } catch(e) {}
+
+    return path;
+};
+
+export const customDecodeURI = (path: string) => {
+    try {
+        return path.split('%2F').map(decodeURIComponent).join('%2F');
+    } catch(e) {}
+
+    return path;
+};