1 export function getUrlParameter(search: string, name: string) {
2 const safeName = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]');
3 const regex = new RegExp('[\\?&]' + safeName + '=([^&#]*)');
4 const results = regex.exec(search);
5 return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' '));
8 export function normalizeURLPath(url: string) {
9 const u = new URL(url);
10 u.pathname = u.pathname.replace(/\/\//, '/');
11 if (u.pathname[u.pathname.length - 1] === '/') {
12 u.pathname = u.pathname.substr(0, u.pathname.length - 1);