linkify icon indicating copy to clipboard operation
linkify copied to clipboard

A URL immediately following a linkified URL doesn't get linkified

Open jibai31 opened this issue 14 years ago • 1 comments

If the text contains 2 consecutive URLS (separated by one space, or one newline), only the first URL gets linkified. This only occurs if the 2 URLs have the same format (eg, both with an http or ftp part, or both without).

Failing examples (only the first URL is linkified): www.github.com www.google.com http://www.github.com http://www.google.com ftp://www.github.com http://www.google.com

But working examples: http://www.github.com www.google.com www.github.com ftp://www.google.com www.github.com www.google.com (with 2 spaces in between)

Issue on Mozilla 6, IE8 and Chrome (didn't test other browsers).

jibai31 avatar Sep 24 '11 06:09 jibai31

One solution to this is to use positive lookaheads to not match the space after each URL. (i.e. noProtocolUrl = /(^|["'(\s]|<)(www..+?..+?)((?:[:?]|.+)?(?=(?:\s|$)|>|[)"',]))/g,)

jwang47 avatar Sep 27 '11 18:09 jwang47