I am using angular linky to find links in the text and convert them to url. But linky doesn't support URL like following:
www.abc.com
abc.xyz
is there any other way to support those links?
linky
filter already supports www.abc.com-like addresses.
And developing regexps by yourself to support abc.xyz
is too complex and thankless job to do it alone. I would suggest to use mature third-party library for that, like Autolinker is.
Here is a simple module that may help to configure (with options supported by Autolinker) and wrap it into Angular filter
angular.module('linkier', ['ngSanitize'])
.constant('linkierConfig', {})
.filter('linkier', ['$window', '$sanitize', 'linkierConfig',
function ($window, $sanitize, linkierConfig) {
return function (input, config) {
if (!angular.isString(input))
return input;
config = angular.extend({}, linkierConfig, angular.isObject(config) ? config : {});
return $sanitize($window.Autolinker.link(input, config));
};
}]);
Finds links in text input and turns them into html links. Supports http/https/ftp/mailto and plain email address links.
So it seems that it doesn't. You should create your own filter to solve this problem. Here's a template to get you started.
angular
.module('app.filters')
.filter('urlLink', urlLink);
function urlLink() {
return function(value) {
var result = '';
// ... logic ...
return result;
}
}
What is the best regular expression to check if a string is a valid URL?