Say I have a URL like such:
https://example.com/cheesey_poofs/../goo
How would I make it parse to something like so?
https://example.com/goo
const url = new URL('https://example.com/cheesey_poofs/../goo');
console.log(url);
A bit long operation using string split
let input = 'https://example.com/cheesey_poofs/../goo';
let input_arr = input.split('//');
let protocol = input_arr[0] + '//';
let url = input_arr[1];
let url_arr = url.split('/');
let result = protocol + [url_arr[0], url_arr[url_arr.length-1]].join('/');
console.log(result);