Skip to content
This repository has been archived by the owner on Apr 4, 2020. It is now read-only.

Commit

Permalink
Fix incorrect parenthesis order (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
colinodell committed Jan 14, 2020
1 parent c13eefe commit 128893c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/UrlAutolinkProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions tests/UrlAutolinkProcessorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public function dataProviderForAutolinkTests()
yield ['www.google.com/search?q=Markup+(business)', '<p><a href="http://www.google.com/search?q=Markup+(business)">www.google.com/search?q=Markup+(business)</a></p>'];
yield ['(www.google.com/search?q=Markup+(business))', '<p>(<a href="http://www.google.com/search?q=Markup+(business)">www.google.com/search?q=Markup+(business)</a>)</p>'];
yield ['www.google.com/search?q=(business))+ok', '<p><a href="http://www.google.com/search?q=(business))+ok">www.google.com/search?q=(business))+ok</a></p>'];
yield ['(https://www.example.com/test).', '<p>(<a href="https://www.example.com/test">https://www.example.com/test</a>).</p>'];

// Tests involving semi-colon endings
yield ['www.google.com/search?q=commonmark&hl=en', '<p><a href="http://www.google.com/search?q=commonmark&amp;hl=en">www.google.com/search?q=commonmark&amp;hl=en</a></p>'];
Expand Down

0 comments on commit 128893c

Please # to comment.