Skip to content

Commit

Permalink
Change UTF8 decode to mbstring (#35)
Browse files Browse the repository at this point in the history
* Change UTF8 decode to mbstring

* Revert polyfill and check if module exists
  • Loading branch information
laoneo authored Jan 11, 2023
1 parent 7748f9a commit 5cc9b0e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
"homepage": "https://github.com/joomla-framework/uri",
"license": "GPL-2.0-or-later",
"require": {
"php": "^7.2.5|~8.0.0|~8.1.0"
"php": "^7.2.5|~8.0.0|~8.1.0|~8.2.0"
},
"suggest": {
"ext-mbstring": "Used to speed up url parsing"
},
"require-dev": {
"joomla/coding-standards": "^3.0@dev",
Expand Down
2 changes: 1 addition & 1 deletion src/UriHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public static function parse_url($url, $component = -1)
$result = [];

// If no UTF-8 chars in the url just parse it using php native parse_url which is faster.
if (utf8_decode($url) === $url)
if (extension_loaded('mbstring') && mb_convert_encoding($url, 'ISO-8859-1', 'UTF-8') === $url)
{
return parse_url($url, $component);
}
Expand Down

0 comments on commit 5cc9b0e

Please sign in to comment.