17426: Add dialog box with form to example plugin.
[arvados-workbench2.git] / src / common / url.ts
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, ' '));
6 }
7
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);
13     }
14     return u.toString();
15 }