Skip to content

Commit 8b92160

Browse files
committed
Exclude trailing parenthesis from URL
I found that when a link was enclosed in parentheses, e.g., (https://google.com), the opening parenthesis was correctly excluded from the URL, but the closing one was included. This is fixed here using the same pattern that excludes closing periods, but there may be a better way (either earlier in the regex, or maybe the exclusions should be in a foreach loop).
1 parent 02b6846 commit 8b92160

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/Autolink.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,11 @@ function ($matches) use ($attribs, $linkNoScheme) {
126126
$url = substr($url, 0, -1);
127127
}
128128

129+
if (str_ends_with($url, ')')) {
130+
$suffix = ')';
131+
$url = substr($url, 0, -1);
132+
}
133+
129134
return $this->link($url, $attribs) . $suffix;
130135
},
131136
$text

0 commit comments

Comments
 (0)