komanda
komanda copied to clipboard
Regexp for images (and others?) are confused by nearby punctuation
These chat messages will embed the specified image:
http://i.imgur.com/aNRAMkp.gif
test test http://i.imgur.com/aNRAMkp.gif
test http://i.imgur.com/aNRAMkp.gif test
... but this one fails (presumably because of the trailing parenthesis):
(i usually add text around them, like this: http://i.imgur.com/aNRAMkp.gif)
See the last regex entry in this discussion: http://www.regexguru.com/2008/11/detecting-urls-in-a-block-of-text/
This works by only allowing matching parenthesis in a URL. So, you don't have to worry about the above case.
I'll look at this more in the next few days, unless someone beats me to it. :)
I just pushed a PR for this.