There are many ways to do it, but I will show how to make it very simple and effective.
var parser = new URL('https://morioh.com/p/480aef8e92cd?f=5db7ed114ed9706bfadc8dc9#hash');
console.log(parser);
Result
{
href: 'https://morioh.com/p/480aef8e92cd?f=5db7ed114ed9706bfadc8dc9#hash',
origin: 'https://morioh.com',
protocol: 'https:',
username: '',
password: '',
host: 'morioh.com',
hostname: 'morioh.com',
port: '',
pathname: '/p/480aef8e92cd',
search: '?f=5db7ed114ed9706bfadc8dc9',
searchParams: URLSearchParams { 'f' => '5db7ed114ed9706bfadc8dc9' },
hash: '#hash'
}
It’s simple right?
#javascript #node #nodejs