From 99525fdd768c5530c1436d01a66ed39793a5f26f Mon Sep 17 00:00:00 2001 From: Aidan Woods Date: Tue, 26 Mar 2019 21:38:21 +0000 Subject: [PATCH] Match GFM spec for extended autolinks There is a small list of characters which may precede an autolink --- src/Components/Inlines/Url.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Components/Inlines/Url.php b/src/Components/Inlines/Url.php index 666a117..48c2430 100644 --- a/src/Components/Inlines/Url.php +++ b/src/Components/Inlines/Url.php @@ -38,7 +38,12 @@ final class Url implements BacktrackingInline */ public static function build(Excerpt $Excerpt, State $State) { - if (\preg_match('/\bhttps?+:[\/]{2}[^\s<]+\b\/*+/ui', $Excerpt->context(), $matches, \PREG_OFFSET_CAPTURE)) { + if (\preg_match( + '/(?<=^|\s|[*_~(])https?+:[\/]{2}[^\s<]+\b\/*+/ui', + $Excerpt->context(), + $matches, + \PREG_OFFSET_CAPTURE + )) { return new self($matches[0][0], \intval($matches[0][1])); }