Closed pdehaan closed 2 years ago
Ref /parser.js:14-22,
function getProvider(url) { return urlparse.parse(url) .hostname .replace(/www[a-zA-Z0-9]*\./, '') .replace('.co.', '.') .split('.') .slice(0, -1) .join(' '); }
The one suspicious bit in there is the .replace(/www[a-zA-Z0-9*\./, '') bit. It looks like [in theory] it would murder any domain that would start with "www", such as "wwwapple.com":
.replace(/www[a-zA-Z0-9*\./, '')
const urlparse = require('url'); function getProvider(url) { return urlparse.parse(url) .hostname .replace(/www[a-zA-Z0-9]*\./, '') .replace('.co.', '.') .split('.') .slice(0, -1) .join(' '); } console.log(getProvider('https://www.apple.com')); // "apple" console.log(getProvider('https://bbc.co.uk')); // "bbc" console.log(getProvider('https://redirect.ca')); // "redirect" console.log(getProvider('https://aol.go.com')); // "aol go" console.log(getProvider('https://wwwwwapple.com')); // ""
Ref /parser.js:14-22,
The one suspicious bit in there is the
.replace(/www[a-zA-Z0-9*\./, '')
bit. It looks like [in theory] it would murder any domain that would start with "www", such as "wwwapple.com":