See this pastebin[1] for the function I believe is determining the url of the active tab and if it has a valid hostname.
There's also this one[2] that seems to be extracting the hostname of a given url also using the URL API.
Both these pastebins contain minimized code that I've cleaned up.
0: https://developer.mozilla.org/en-US/docs/Web/API/URL
1: http://pastebin.com/tWns7XmG
2: http://pastebin.com/PXS1iqsq