Skip to content

Commit

Permalink
Fix links followed by hyphen
Browse files Browse the repository at this point in the history
  • Loading branch information
rlidwka committed Apr 20, 2022
1 parent eb7463d commit ce64cfa
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/re.js
Expand Up @@ -42,7 +42,13 @@ module.exports = function (opts) {

re.src_host_terminator =

'(?=$|' + text_separators + '|' + re.src_ZPCc + ')(?!-|_|:\\d|\\.-|\\.(?!$|' + re.src_ZPCc + '))';
'(?=' +
'$|' + text_separators + '|' + re.src_ZPCc +
')' +
'(?!' +
(opts && opts['---'] ? '-(?!--)|' : '-|') +
'_|:\\d|\\.-|\\.(?!$|' + re.src_ZPCc + ')' +
')';

re.src_path =

Expand Down
2 changes: 2 additions & 0 deletions test/test.js
Expand Up @@ -276,10 +276,12 @@ describe('API', function () {
var l = linkify();

assert.strictEqual(l.match('http://e.com/foo---bar')[0].text, 'http://e.com/foo---bar');
assert.strictEqual(l.match('text@example.com---foo'), null);

l = linkify(null, { '---': true });

assert.strictEqual(l.match('http://e.com/foo---bar')[0].text, 'http://e.com/foo');
assert.strictEqual(l.match('text@example.com---foo')[0].text, 'text@example.com');
});

it('should find a match at the start', function () {
Expand Down

0 comments on commit ce64cfa

Please sign in to comment.