17782: Fixes absolute import paths from '~/somedir/...' to 'somedir/...'
[arvados-workbench2.git] / src / common / url.ts
index 7a9a5158a6ad8a184b2d23ef87a8a7c709e8ba76..185737cac331d2a6a5eece01e8f99f293f76c230 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,12 +28,8 @@ 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;
 };
-
-export const encodeHash = (path: string) => {
-    return path.replace(/#/g, '%23');
-};
\ No newline at end of file