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 #30 from Garfield-fr/allow_comma
Browse files Browse the repository at this point in the history
Allow commas in URLs
  • Loading branch information
lsmith77 committed Dec 11, 2015
2 parents 2f7c3e0 + 3bc6fe8 commit 536dd00
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 @@ -61,7 +61,7 @@ public function getFilters()
*/
public function autoConvertUrls($string)
{
$pattern = '/(href="|src=")?([-a-zA-Zа-яёА-ЯЁ0-9@:%_\+.~#?&\/\/=]{2,256}\.[a-zа-яё]{2,4}\b(\/?[-\p{L}0-9@:%_\+.~#?&\/\/=\(\)]*)?)/u';
$pattern = '/(href="|src=")?([-a-zA-Zа-яёА-ЯЁ0-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 @@ -134,6 +134,10 @@ public function provider()
'Lorem ipsum dolor sit amet, <a href="http://тест.рф" class="" target="">http://тест.рф</a> consectetuer.',
'Lorem ipsum dolor sit amet, http://тест.рф consectetuer.',
),
array(
'Lorem ipsum dolor sit amet, <a href="http://test.com/foo,_bar" class="" target="">http://test.com/foo,_bar</a> consectetuer.',
'Lorem ipsum dolor sit amet, http://test.com/foo,_bar consectetuer.',
),
);
}

Expand Down

0 comments on commit 536dd00

Please sign in to comment.