From 128893ca6dcdf42fcc3466863fc3a505c772d8b1 Mon Sep 17 00:00:00 2001 From: Colin O'Dell Date: Mon, 13 Jan 2020 20:52:09 -0500 Subject: [PATCH] Fix incorrect parenthesis order (#13) --- CHANGELOG.md | 4 ++++ src/UrlAutolinkProcessor.php | 2 +- tests/UrlAutolinkProcessorTest.php | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8dfaf3c..79dcf68 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased][unreleased] +### Fixed + + - Fixed incorrect parenthesis order (#13) + ## [1.0.0] - 2019-06-29 No changes have been introduced since 1.0.0-beta3. diff --git a/src/UrlAutolinkProcessor.php b/src/UrlAutolinkProcessor.php index 49bd689..b36a3ce 100644 --- a/src/UrlAutolinkProcessor.php +++ b/src/UrlAutolinkProcessor.php @@ -105,7 +105,7 @@ private static function processAutolinks(Text $node, $regex) // Does the URL need its closing paren chopped off? if (\substr($content, -1) === ')' && self::hasMoreCloserParensThanOpeners($content)) { $content = \substr($content, 0, -1); - $leftovers .= ')'; + $leftovers = ')' . $leftovers; } self::addLink($node, $content); diff --git a/tests/UrlAutolinkProcessorTest.php b/tests/UrlAutolinkProcessorTest.php index f3502b5..0b9ac90 100644 --- a/tests/UrlAutolinkProcessorTest.php +++ b/tests/UrlAutolinkProcessorTest.php @@ -62,6 +62,7 @@ public function dataProviderForAutolinkTests() yield ['www.google.com/search?q=Markup+(business)', '

www.google.com/search?q=Markup+(business)

']; yield ['(www.google.com/search?q=Markup+(business))', '

(www.google.com/search?q=Markup+(business))

']; yield ['www.google.com/search?q=(business))+ok', '

www.google.com/search?q=(business))+ok

']; + yield ['(https://www.example.com/test).', '

(https://www.example.com/test).

']; // Tests involving semi-colon endings yield ['www.google.com/search?q=commonmark&hl=en', '

www.google.com/search?q=commonmark&hl=en

'];