From 2cbc7537e5496ddc99b53c12c706105faff5581e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E5=A4=AA?= Date: Tue, 17 Sep 2013 23:22:12 +1000 Subject: [PATCH] Add port number detection to automatic links --- js/battledata.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/js/battledata.js b/js/battledata.js index 2b1f4989d..50ba0590e 100644 --- a/js/battledata.js +++ b/js/battledata.js @@ -317,13 +317,13 @@ var Tools = { options.hidestrikethrough ? '$1' : '$1'); // linking of URIs if (!options.hidelinks) { - str = str.replace(/(https?\:\/\/[a-z0-9-.]+(\/([^\s]*[^\s?.,])?)?|[a-z0-9]([a-z0-9-\.]*[a-z0-9])?\.(com|org|net|edu|us)((\/([^\s]*[^\s?.,])?)?|\b))/ig, function(uri) { + str = str.replace(/(https?\:\/\/[a-z0-9-.]+(\:[0-9]+)?(\/([^\s]*[^\s?.,])?)?|[a-z0-9]([a-z0-9-\.]*[a-z0-9])?\.(com|org|net|edu|us)(\:[0-9]+)?((\/([^\s]*[^\s?.,])?)?|\b))/ig, function(uri) { // Insert http:// before URIs without a URI scheme specified. var fulluri = uri.replace(/^([a-z]*[^a-z:])/g, 'http://$1'); var onclick; var r = new RegExp('^https?://' + document.location.hostname.replace(/\./g, '\\.') + - '/([a-zA-Z0-9-]+)$'); + '(\\:[0-9]+)?/([a-zA-Z0-9-]+)$'); var m = r.exec(fulluri); if (m) { onclick = "return selectTab('" + m[1] + "');"; @@ -891,4 +891,3 @@ var Tools = { return ''+type+''; } }; -