Skip to content

Commit 688e322

Browse files
authored
Merge pull request #115 from kmiyauchi/master
extLink module fix
2 parents 1f6b32c + 8d25070 commit 688e322

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

lib/util/jquery.extLink.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,12 @@ var extLink = exports.extLink = function extLink($, _config) {
3939
}
4040

4141
// Strip the host name down, removing ports, subdomains, or www.
42-
var pattern = /^(([^\/:]+?\.)*)([^\.:]{1,})((\.[a-z0-9]{1,253})*)(:[0-9]{1,5})?$/;
42+
var pattern = /^(([^\/:]+?\.)*)([^\.:]{4,})((\.[a-z]{1,4})*)(:[0-9]{1,5})?$/;
4343
var host = window.location.host.replace(pattern, '$3$4');
4444
var subdomain = window.location.host.replace(pattern, '$1');
45+
if (subdomain == host) {
46+
subdomain = "";
47+
}
4548

4649
// Determine what subdomains are considered internal.
4750
var subdomains;

src/util/jquery.extLink.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,12 @@ export const extLink = ($, _config) => {
3131
}
3232

3333
// Strip the host name down, removing ports, subdomains, or www.
34-
var pattern = /^(([^\/:]+?\.)*)([^\.:]{1,})((\.[a-z0-9]{1,253})*)(:[0-9]{1,5})?$/;
34+
var pattern = /^(([^\/:]+?\.)*)([^\.:]{4,})((\.[a-z]{1,4})*)(:[0-9]{1,5})?$/;
3535
var host = window.location.host.replace(pattern, '$3$4');
3636
var subdomain = window.location.host.replace(pattern, '$1');
37+
if (subdomain == host) {
38+
subdomain = "";
39+
}
3740

3841
// Determine what subdomains are considered internal.
3942
var subdomains;

0 commit comments

Comments
 (0)