Revert "convert entire words as urls or do nothing"
This commit is contained in:
parent
f39fe804b1
commit
23833dbab0
|
@ -68,30 +68,20 @@ weechat.filter('conditionalLinkify', ['$filter', function($filter) {
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return linkifyStr(text, {
|
||||||
return text.replaceAll(/\S+/g, function (match, p2) {
|
className: '',
|
||||||
const result = linkifyStr(match, {
|
attributes: {
|
||||||
className: '',
|
rel: 'noopener noreferrer'
|
||||||
attributes: {
|
},
|
||||||
rel: 'noopener noreferrer'
|
target: {
|
||||||
},
|
url: '_blank'
|
||||||
target: {
|
},
|
||||||
url: '_blank'
|
validate: {
|
||||||
},
|
email: function () {
|
||||||
validate: {
|
return false; //Do not linkify emails
|
||||||
email: function () {
|
|
||||||
return false; //Do not linkify emails
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
if (result.endsWith("</a>")) {
|
|
||||||
return result;
|
|
||||||
} else {
|
|
||||||
return match
|
|
||||||
}
|
}
|
||||||
|
});
|
||||||
});
|
|
||||||
};
|
};
|
||||||
}]);
|
}]);
|
||||||
|
|
||||||
|
|
|
@ -21,30 +21,15 @@ describe('Filters', function() {
|
||||||
var url = 'asdf https://a.example.com/wiki/asdf_qwer_(rivi%C3%A8re) Some text.',
|
var url = 'asdf https://a.example.com/wiki/asdf_qwer_(rivi%C3%A8re) Some text.',
|
||||||
link = 'asdf <a href="https://a.example.com/wiki/asdf_qwer_(rivi%C3%A8re)" target="_blank" rel="noopener noreferrer">https://a.example.com/wiki/asdf_qwer_(rivi%C3%A8re)</a> Some text.',
|
link = 'asdf <a href="https://a.example.com/wiki/asdf_qwer_(rivi%C3%A8re)" target="_blank" rel="noopener noreferrer">https://a.example.com/wiki/asdf_qwer_(rivi%C3%A8re)</a> Some text.',
|
||||||
result = $filter('conditionalLinkify')(url);
|
result = $filter('conditionalLinkify')(url);
|
||||||
expect(result).toEqual(link);
|
expect(result).toEqual(link);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it('should not make emails into links', angular.mock.inject(function($filter) {
|
it('should not make emails into links', angular.mock.inject(function($filter) {
|
||||||
var url = 'asdf@gmail.com',
|
var url = 'asdf@gmail.com',
|
||||||
link = 'asdf@gmail.com',
|
link = 'asdf@gmail.com',
|
||||||
result = $filter('conditionalLinkify')(url);
|
result = $filter('conditionalLinkify')(url);
|
||||||
expect(result).toEqual(link);
|
expect(result).toEqual(link);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it('convert the entire words to links', angular.mock.inject(function($filter) {
|
|
||||||
var text = 'weechat.network.connection_timeout',
|
|
||||||
link = 'weechat.network.connection_timeout',
|
|
||||||
result = $filter('conditionalLinkify')(text);
|
|
||||||
expect(result).toEqual(link);
|
|
||||||
}));
|
|
||||||
|
|
||||||
it('linkify parenthesis at the end of an url', angular.mock.inject(function($filter) {
|
|
||||||
var text = 'http://test.com/(test)',
|
|
||||||
link = '<a href="http://test.com/(test)" target="_blank" rel="noopener noreferrer">http://test.com/(test)</a>',
|
|
||||||
result = $filter('conditionalLinkify')(text);
|
|
||||||
expect(result).toEqual(link);
|
|
||||||
}));
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('irclinky', function() {
|
describe('irclinky', function() {
|
||||||
|
@ -168,6 +153,6 @@ describe('Filters', function() {
|
||||||
expect(codifyFilter('Weird`ness`')).toEqual('Weird`ness`');
|
expect(codifyFilter('Weird`ness`')).toEqual('Weird`ness`');
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue