+
+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.substring(0, u.pathname.length - 1);
+ }
+ return u.toString();
+}
+
+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;
+};