// 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, ' '));
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) => {
+ 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;
+};