tot - Check-in [43]
Not logged in
[Browse]  [Home]  [Login]  [Reports]  [Search]  [Timeline
  [Patchset
Check-in Number: 43
Date: 2008-Oct-25 10:20:46 (local)
2008-Oct-25 08:20:46 (UTC)
User:rse
Branch:
Comment: try to be more precise in matching
Tickets:
Inspections:
Files:
jquery/jquery.extlink.js      42 -> 43
Modified: jquery/jquery.extlink.js
===================================================================
--- jquery/jquery.extlink.js	2008-10-25 08:09:54 UTC (rev 42)
+++ jquery/jquery.extlink.js	2008-10-25 08:20:46 UTC (rev 43)
@@ -14,21 +14,31 @@
                 color = "grey";
             if (typeof prefix === "undefined")
                 prefix = "";
-            var site = String(document.location)
+            var url_prefix = String(document.location)
                 .replace(/^(https?:\/\/[^:\/]+).*$/, "$1")
                 .replace(/^((site)?file:\/\/.+\/)[^\/]+$/, "$1")
                 .replace(/(\\.)/g, "\\$1");
+            var host_name = String(document.location)
+                .replace(/^/, "X")
+                .replace(/^X(https?|ftp):\/\/([^:\/]+).*$/, "$1")
+                .replace(/^X.*$/, "")
+                .replace(/(\\.)/g, "\\$1");
             $("a", this).filter(function (i) {
                 var href = $(this).attr("href");
                 if (href == null)
                     return false;
                 return (
-                       href.match(RegExp("^("+site+"|(https?:)?/[^/])")) == null
+                       href.match(RegExp(
+                           "^(" + url_prefix + ".*" +
+                           (hostname != "" ? ("|" + "(https?|ftp)://" + host_name + "([/:].*)?") : "") +
+                           "|" + "((https?|ftp):)?/[^/].*" +
+                           ")$"
+                       )) == null
                     && href.match(RegExp("^(https?|ftp)://.+")) != null
                 );
             }).each(function () {
                 $(this)
-                    .css("backgroundImage",    "url('"+prefix+"jquery.extlink.d/extlink-" + color + ".gif')")
+                    .css("backgroundImage",    "url('" + prefix + "jquery.extlink.d/extlink-" + color + ".gif')")
                     .css("backgroundRepeat",   "no-repeat")
                     .css("backgroundPosition", "right center")
                     .css("padding-right",      "11px");