Skip to content

Commit 8626545

Browse files
committed
Fix handling errors on hosts with custom port
1 parent de3d729 commit 8626545

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

background.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ function formatStackForPopup(stack) {
1717
}
1818

1919
function getBaseHostByUrl(url) {
20-
var localUrlRegexp = /(file:\/\/.*)|(:\/\/[^.:]+([\/?]|$))/;
21-
var rootHostRegexp = /:\/\/(([\w-]+\.\w+)|(\d+\.\d+\.\d+\.\d+)|(\w+:\w+:\w+:[\w:]+))([\/?]|$)/;
22-
var subDomainRegexp = /:\/\/.*\.([\w-]+\.\w+)([\/?]|$)/;
20+
var localUrlRegexp = /(file:\/\/.*)|(:\/\/[^.:]+([\/?]|$))/; // file://
21+
var rootHostRegexp = /:\/\/(([\w-]+\.\w+)|(\d+\.\d+\.\d+\.\d+)|(\[[\w:]+\]))([\/?:]|$)/; // domain.com | IPv4 | IPv6
22+
var subDomainRegexp = /:\/\/.*\.([\w-]+\.\w+)([\/?:]|$)/; // sub.domain.com
2323
return localUrlRegexp.exec(url) ? 'localhost' : (rootHostRegexp.exec(url) || subDomainRegexp.exec(url))[1];
2424
}
2525

0 commit comments

Comments
 (0)