From d2a6a38db2e7f379b997fa6af01c9e2d0061bf9c Mon Sep 17 00:00:00 2001 From: gorhill Date: Wed, 18 Mar 2015 07:13:53 -0400 Subject: [PATCH] related to #953 --- src/js/uritools.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/js/uritools.js b/src/js/uritools.js index a88c327fe..d47a913f2 100644 --- a/src/js/uritools.js +++ b/src/js/uritools.js @@ -49,6 +49,7 @@ var reRFC3986 = /^([^:\/?#]+:)?(\/\/[^\/?#]*)?([^?#]*)(\?[^#]*)?(#.*)?/; // Derived var reSchemeFromURI = /^[^:\/?#]+:/; var reAuthorityFromURI = /^(?:[^:\/?#]+:)?(\/\/[^\/?#]+)/; +var reCommonHostnameFromURL = /^https?:\/\/([0-9a-z_][0-9a-z._-]+)\//; // These are to parse authority field, not parsed by above official regex // IPv6 is seen as an exception: a non-compatible IPv6 is first tried, and @@ -248,7 +249,11 @@ URI.authorityFromURI = function(uri) { // The most used function, so it better be fast. URI.hostnameFromURI = function(uri) { - var matches = reAuthorityFromURI.exec(uri); + var matches = reCommonHostnameFromURL.exec(uri); + if ( matches ) { + return matches[1]; + } + matches = reAuthorityFromURI.exec(uri); if ( !matches ) { return ''; }