snippet

Parse url on Node.js

const url = new URL('https://user:[email protected]:8080/p/a/t/h?query=string#hash');

// url.hostname return example.com
// url.protocol return https
// url.port return 8080
// url.pathname return /p/a/t/h
// url.hash return hash
// url.search return query=string