const parseUrl = require('parse-url'); const url = 'softhunt.net:3000/path/to/index.html#anchor'; const parsedUrl = parseUrl(url, true); console.log(parsedUrl);