|
|
@@ -32,18 +32,23 @@ angular.module('kibana.filters', [])
|
|
|
return arr.toString();
|
|
|
}
|
|
|
};
|
|
|
-
|
|
|
}).filter('noXml', function() {
|
|
|
- return function(text) {
|
|
|
- if(!_.isString(text)) {
|
|
|
- return text;
|
|
|
- }
|
|
|
- return text.
|
|
|
+ var noXml = function(text) {
|
|
|
+ return _.isString(text) ?
|
|
|
+ text.
|
|
|
replace(/&/g, '&').
|
|
|
replace(/</g, '<').
|
|
|
replace(/>/g, '>').
|
|
|
replace(/'/g, ''').
|
|
|
- replace(/"/g, '"');
|
|
|
+ replace(/"/g, '"') :
|
|
|
+ text;
|
|
|
+ };
|
|
|
+ return function(text) {
|
|
|
+ return _.isArray(text) ?
|
|
|
+ _.map(text,function(t) {
|
|
|
+ return noXml(t);
|
|
|
+ }) :
|
|
|
+ noXml(text);
|
|
|
};
|
|
|
}).filter('urlLink', function() {
|
|
|
var //URLs starting with http://, https://, or ftp://
|
|
|
@@ -53,20 +58,35 @@ angular.module('kibana.filters', [])
|
|
|
//Change email addresses to mailto:: links.
|
|
|
r3 = /(\w+@[a-zA-Z_]+?\.[a-zA-Z]{2,6})/gim;
|
|
|
|
|
|
- return function(text, target, otherProp) {
|
|
|
+ var urlLink = function(text) {
|
|
|
+ var t1,t2,t3;
|
|
|
if(!_.isString(text)) {
|
|
|
return text;
|
|
|
+ } else {
|
|
|
+ var i=1;
|
|
|
+ _.each(text.match(r1), function(url) {
|
|
|
+ t1 = text.replace(r1, "<a href=\"$1\" target=\"_blank\">$1</a>");
|
|
|
+ });
|
|
|
+ text = t1 || text;
|
|
|
+ _.each(text.match(r2), function(url) {
|
|
|
+ t2 = text.replace(r2, "$1<a href=\"http://$2\" target=\"_blank\">$2</a>");
|
|
|
+ });
|
|
|
+ text = t2 || text;
|
|
|
+ _.each(text.match(r3), function(url) {
|
|
|
+ t3 = text.replace(r3, "<a href=\"mailto:$1\">$1</a>");
|
|
|
+ });
|
|
|
+ text = t3 || text;
|
|
|
+ return text;
|
|
|
}
|
|
|
- _.each(text.match(r1), function(url) {
|
|
|
- text = text.replace(r1, "<a href=\"$1\" target=\"_blank\">$1</a>");
|
|
|
- });
|
|
|
- _.each(text.match(r2), function(url) {
|
|
|
- text = text.replace(r2, "$1<a href=\"http://$2\" target=\"_blank\">$2</a>");
|
|
|
- });
|
|
|
- _.each(text.match(r3), function(url) {
|
|
|
- text = text.replace(r3, "<a href=\"mailto:$1\">$1</a>");
|
|
|
- });
|
|
|
- return text;
|
|
|
+ };
|
|
|
+
|
|
|
+ return function(text, target, otherProp) {
|
|
|
+
|
|
|
+ return _.isArray(text) ?
|
|
|
+ _.map(text,function(t) {
|
|
|
+ return urlLink(t);
|
|
|
+ }) :
|
|
|
+ urlLink(text);
|
|
|
};
|
|
|
}).filter('gistid', function() {
|
|
|
var gist_pattern = /(\d{5,})|([a-z0-9]{10,})|(gist.github.com(\/*.*)\/[a-z0-9]{5,}\/*$)/;
|