X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/f5f72a4ee9b00aab5492f8991677b6503a6f2ac3..e16f2125588512201e3bd22ae9a19e10cb69d367:/src/common/url.ts diff --git a/src/common/url.ts b/src/common/url.ts index 7a9a5158a6..db12cb8ea8 100644 --- a/src/common/url.ts +++ b/src/common/url.ts @@ -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, ' ')); @@ -13,14 +13,14 @@ 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); + u.pathname = u.pathname.substring(0, u.pathname.length - 1); } return u.toString(); } 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