ember-linkify icon indicating copy to clipboard operation
ember-linkify copied to clipboard

Consider supporting multiple links separated by punctuation

Open nwhittaker opened this issue 9 years ago • 9 comments

Given the strings:

  • http://www.a.com http://www.b.com
  • http://www.a.com, http://www.b.com, and http://www.c.com.

Expected output:

  • <a href="http://www.a.com" target="_self">http://www.a.com</a> <a href="http://www.b.com" target="_self">http://www.b.com</a>
  • <a href="http://www.a.com" target="_self">http://www.a.com</a>, <a href="http://www.b.com" target="_self">http://www.b.com</a>, and <a href="http://www.c.com" target="_self">http://www.c.com</a>.

Observed output:

  • <a href="http://www.a.com" target="_self">http://www.a.com</a> http://www.b.com
  • http://www.a.com, http://www.b.com, and http://www.c.com.

nwhittaker avatar Apr 20 '16 20:04 nwhittaker

FWIW,

  • http://www.a.com, ... yields http://www.a.com, ..., however appending a slash http://www.a.com/, ... yields (note the trailing punctuation is included in the link) <a href="http://www.a.com/," target="_self">http://www.a.com/,</a> ...
  • and separating links with multiple spaces (spaces not preserved by Markdown) http://www.a.com http://www.b.com yields <a href="http://www.a.com" target="_self">http://www.a.com</a> <a href="//www.b.com" target="_self">www.b.com</a>

nwhittaker avatar Apr 20 '16 20:04 nwhittaker

Thanks for opening this issue! Definitely agree that we should support this better. When I get a chance I will dive into the regex a bit to see how I can get the expected output to be produced.

johno avatar Apr 21 '16 18:04 johno

+1 for this.

netes avatar Jun 15 '16 10:06 netes

+1

killerbytes avatar Sep 06 '16 01:09 killerbytes

Version 3.0.0 handles space delimited list of URLs as expected now

kamikaz1k avatar Apr 17 '17 19:04 kamikaz1k

Want me to split the comma-delimited issue into a separate issue? IMO that's the more likely use-case.

nwhittaker avatar Apr 17 '17 19:04 nwhittaker

@nwhittaker I'll reopen it so we're tracking against the punctuation case.

kamikaz1k avatar Apr 17 '17 19:04 kamikaz1k

@nwhittaker I have a PR for this. Can you drop in and give some input?

kamikaz1k avatar Apr 20 '17 23:04 kamikaz1k

Any way to detect the delimiter programmatically? Or at least make a best guess? I suspect the typical usage of this helper (at least it is in my case) is to pass it dynamic or user-entered content. So the delimiter isn't always knowable (or guaranteed consistent) ahead of time.

nwhittaker avatar Apr 21 '17 01:04 nwhittaker