diff --git a/index.html b/index.html
index cac5e34..208f005 100644
--- a/index.html
+++ b/index.html
@@ -25,6 +25,8 @@
+
+
diff --git a/js/filters.js b/js/filters.js
index 193abcf..8fe607c 100644
--- a/js/filters.js
+++ b/js/filters.js
@@ -66,7 +66,21 @@ weechat.filter('conditionalLinkify', ['$filter', function($filter) {
if (!text || disable) {
return text;
}
- return $filter('linky')(text, '_blank', {rel:'noopener noreferrer'});
+
+ return linkifyStr(text, {
+ className: '',
+ attributes: {
+ rel: 'noopener noreferrer'
+ },
+ target: {
+ url: '_blank'
+ },
+ validate: {
+ email: function () {
+ return false; //Do not linkify emails
+ }
+ }
+ });
};
}]);
diff --git a/package.json b/package.json
index d7ae807..e741902 100644
--- a/package.json
+++ b/package.json
@@ -15,7 +15,8 @@
"karma": "^5.1.0",
"karma-jasmine": "~3.1",
"karma-junit-reporter": "~2.0",
- "karma-phantomjs-launcher": "^1.0.0",
+ "karma-phantomjs-launcher": "^1.0.4",
+ "linkifyjs": "^2.1.9",
"protractor": "^7.0.0",
"shelljs": "^0.8.4",
"uglify-js": "^3.10.0"
diff --git a/test/karma.conf.js b/test/karma.conf.js
index 43c86e7..0216f59 100644
--- a/test/karma.conf.js
+++ b/test/karma.conf.js
@@ -10,6 +10,8 @@ module.exports = function(config){
'bower_components/angular-sanitize/angular-sanitize.js',
'bower_components/angular-touch/angular-touch.js',
'bower_components/underscore/underscore.js',
+ 'node_modules/linkifyjs/dist/linkify.js',
+ 'node_modules/linkifyjs/dist/linkify-string.js',
'js/localstorage.js',
'js/weechat.js',
'js/irc-utils.js',
diff --git a/test/unit/filters.js b/test/unit/filters.js
index ebd6e39..4f0e189 100644
--- a/test/unit/filters.js
+++ b/test/unit/filters.js
@@ -10,6 +10,22 @@ describe('Filters', function() {
expect($filter('irclinky')).not.toBeNull();
}));
+ describe('conditionalLinkify', function() {
+ it('should create links from an url', inject(function($filter) {
+ var url = 'asdf https://a.example.com/wiki/asdf_qwer_(rivi%C3%A8re) Some text.',
+ link = 'asdf https://a.example.com/wiki/asdf_qwer_(rivi%C3%A8re) Some text.',
+ result = $filter('conditionalLinkify')(url);
+ expect(result).toEqual(link);
+ }));
+
+ it('should not make emails into links', inject(function($filter) {
+ var url = 'asdf@gmail.com',
+ link = 'asdf@gmail.com',
+ result = $filter('conditionalLinkify')(url);
+ expect(result).toEqual(link);
+ }));
+ });
+
describe('irclinky', function() {
it('should not mess up text', inject(function(irclinkyFilter) {
expect(irclinkyFilter('foo')).toEqual('foo');
@@ -23,9 +39,9 @@ describe('Filters', function() {
expect(irclinkyFilter('<"#foo">')).toEqual('<"\');">#foo">');
}));
- it('should not touch links created by `linky`', inject(function(linkyFilter, DOMfilterFilter) {
+ it('should not touch links created by `linky`', inject(function($filter, DOMfilterFilter) {
var url = 'http://foo.bar/#baz',
- link = linkyFilter(url, '_blank'),
+ link = $filter('conditionalLinkify')(url),
result = DOMfilterFilter(link, 'irclinky').$$unwrapTrustedValue();
expect(result).toEqual(link);
}));
@@ -84,9 +100,9 @@ describe('Filters', function() {
expect(result).toEqual(expected);
}));
- it('should never lock up like in bug #688', inject(function(linkyFilter, DOMfilterFilter) {
+ it('should never lock up like in bug #688', inject(function($filter, DOMfilterFilter) {
var msg = '#crash http://google.com',
- linked = linkyFilter(msg),
+ linked = $filter('conditionalLinkify')(msg),
irclinked = DOMfilterFilter(linked, 'irclinky');
// With the bug, the DOMfilterFilter call ends up in an infinite loop.
// I.e. if we ever got this far, the bug is fixed.