Commit bb3419e7 by Sam Padgett Committed by GitHub

Merge pull request #226 from spadgett/linkify-regex

Tighten down linkify URL matching
parents f379331b 1a7413f4
...@@ -2215,7 +2215,7 @@ angular.module("openshiftCommonUI") ...@@ -2215,7 +2215,7 @@ angular.module("openshiftCommonUI")
} }
// Replace any URLs with links. // Replace any URLs with links.
return text.replace(/https?:\/\/[A-Za-z0-9._%+-]+\S*[^\s.;,(){}<>"\u201d\u2019]/gm, function(str) { return text.replace(/https?:\/\/[A-Za-z0-9._%+-]+[^\s<]*[^\s.,()\[\]{}<>"\u201d\u2019]/gm, function(str) {
if (target) { if (target) {
return "<a href=\"" + str + "\" target=\"" + target + "\">" + str + " <i class=\"fa fa-external-link\" aria-hidden=\"true\"></i></a>"; return "<a href=\"" + str + "\" target=\"" + target + "\">" + str + " <i class=\"fa fa-external-link\" aria-hidden=\"true\"></i></a>";
} }
......
...@@ -5918,7 +5918,7 @@ angular.module("openshiftCommonUI") ...@@ -5918,7 +5918,7 @@ angular.module("openshiftCommonUI")
} }
// Replace any URLs with links. // Replace any URLs with links.
return text.replace(/https?:\/\/[A-Za-z0-9._%+-]+\S*[^\s.;,(){}<>"\u201d\u2019]/gm, function(str) { return text.replace(/https?:\/\/[A-Za-z0-9._%+-]+[^\s<]*[^\s.,()\[\]{}<>"\u201d\u2019]/gm, function(str) {
if (target) { if (target) {
return "<a href=\"" + str + "\" target=\"" + target + "\">" + str + " <i class=\"fa fa-external-link\" aria-hidden=\"true\"></i></a>"; return "<a href=\"" + str + "\" target=\"" + target + "\">" + str + " <i class=\"fa fa-external-link\" aria-hidden=\"true\"></i></a>";
} }
......
...@@ -2630,7 +2630,7 @@ return !0; ...@@ -2630,7 +2630,7 @@ return !0;
} }
}, },
linkify:function(text, target, alreadyEscaped) { linkify:function(text, target, alreadyEscaped) {
return text ? (alreadyEscaped || (text = _.escape(text)), text.replace(/https?:\/\/[A-Za-z0-9._%+-]+\S*[^\s.;,(){}<>"\u201d\u2019]/gm, function(str) { return text ? (alreadyEscaped || (text = _.escape(text)), text.replace(/https?:\/\/[A-Za-z0-9._%+-]+[^\s<]*[^\s.,()\[\]{}<>"\u201d\u2019]/gm, function(str) {
return target ? '<a href="' + str + '" target="' + target + '">' + str + ' <i class="fa fa-external-link" aria-hidden="true"></i></a>' :'<a href="' + str + '">' + str + "</a>"; return target ? '<a href="' + str + '" target="' + target + '">' + str + ' <i class="fa fa-external-link" aria-hidden="true"></i></a>' :'<a href="' + str + '">' + str + "</a>";
})) :text; })) :text;
} }
......
...@@ -100,7 +100,7 @@ angular.module("openshiftCommonUI") ...@@ -100,7 +100,7 @@ angular.module("openshiftCommonUI")
} }
// Replace any URLs with links. // Replace any URLs with links.
return text.replace(/https?:\/\/[A-Za-z0-9._%+-]+\S*[^\s.;,(){}<>"\u201d\u2019]/gm, function(str) { return text.replace(/https?:\/\/[A-Za-z0-9._%+-]+[^\s<]*[^\s.,()\[\]{}<>"\u201d\u2019]/gm, function(str) {
if (target) { if (target) {
return "<a href=\"" + str + "\" target=\"" + target + "\">" + str + " <i class=\"fa fa-external-link\" aria-hidden=\"true\"></i></a>"; return "<a href=\"" + str + "\" target=\"" + target + "\">" + str + " <i class=\"fa fa-external-link\" aria-hidden=\"true\"></i></a>";
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment