17337: Added another edge case handling
[arvados-workbench2.git] / src / common / url.ts
index 7a9a5158a6ad8a184b2d23ef87a8a7c709e8ba76..16dc6170a4d5f38d6fbc4324e133b7c8d68d4a8a 100644 (file)
@@ -20,7 +20,7 @@ export function normalizeURLPath(url: string) {
 
 export const customEncodeURI = (path: string) => {
     try {
-        return encodeURIComponent(path).replace(/%2F/g, '/');
+        return path.split('/').map(encodeURIComponent).join('/');
     } catch(e) {}
 
     return path;
@@ -28,7 +28,7 @@ export const customEncodeURI = (path: string) => {
 
 export const customDecodeURI = (path: string) => {
     try {
-        return decodeURIComponent(path.replace(/\//g, '%2F'));
+        return path.split('%2F').map(decodeURIComponent).join('%2F');
     } catch(e) {}
 
     return path;