This method is part of a module; And despite the error...
Uncaught TypeError: Cannot read property \'1\' of null(…)
works to a small degree, howeve
String#match returns either null (no match) or an array with the matches.
null
var domain = link.href.match(/(https?:\/\/.+?)\//)[1]; // ^^^^^
Workaround with check
var domain = link.href.match(/(https?:\/\/.+?)\//); if (domain) { // do something with domain[1] }