17337: Added custom encode functions with tests
[arvados-workbench2.git] / src / common / url.ts
index 6223485eabee6908fa363ea94e7345c1c54d7822..0d2549c1b9fc55cb6b123833ab30e29d4e3aa083 100644 (file)
@@ -18,9 +18,14 @@ 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) => {
+    return encodeURIComponent(path.replace(/%2F/g, '/'));
+};
+
+export const customDecodeURI = (path: string) => {
+    return decodeURIComponent(path.replace(/\//g, '%2F'));
+};
+
+export const encodeHash = (path: string) => {
+    return path.replace(/#/g, '%23');
+};
\ No newline at end of file