Skip to content
This repository has been archived by the owner on Dec 5, 2017. It is now read-only.

Commit

Permalink
Merge pull request #18 from thomasthiry/master
Browse files Browse the repository at this point in the history
Added support for parentheses and accents in url locations
  • Loading branch information
dbu committed May 13, 2014
2 parents e08ef6f + fd20366 commit cf7eea1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Extension/UrlAutoConverterTwigExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function getFilters()
*/
public function autoConvertUrls($string)
{
$pattern = '/(href=")?([-a-zA-Z0-9@:%_\+.~#?&\/\/=]{2,256}\.[a-z]{2,4}\b(\/[-\p{L}0-9@:%_\+.~#?&\/\/=\(\)]*)?)/u';
$pattern = '/(href=")?([-a-zA-Z0-9@:%_\+.~#?&\/\/=]{2,256}\.[a-z]{2,4}\b(\/?[-\p{L}0-9@:%_\+.~#?&\/\/=\(\)]*)?)/u';
$stringFiltered = preg_replace_callback($pattern, array($this, 'callbackReplace'), $string);

return $stringFiltered;
Expand Down
4 changes: 4 additions & 0 deletions Tests/Extension/UrlAutoConverterTwigExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@ public function provider()
'Lorem ipsum dolor sit amet, <a href="http://www.test.com/my_page(with_parentheses).htm" class="" target="">http://www.test.com/my_page(with_parentheses).htm</a> consectetuer.',
'Lorem ipsum dolor sit amet, http://www.test.com/my_page(with_parentheses).htm consectetuer.'
),
array(
'Lorem ipsum dolor sit amet, <a href="http://test.com?param=1" class="" target="">http://test.com?param=1</a> consectetuer.',
'Lorem ipsum dolor sit amet, http://test.com?param=1 consectetuer.'
),
);
}

Expand Down

0 comments on commit cf7eea1

Please sign in to comment.