Skip to content

Commit

Permalink
Merge pull request #464 from AleksandrPanarin/wikipedia-url-encode
Browse files Browse the repository at this point in the history
Added encoding of Wikipedia urls
  • Loading branch information
oscarotero authored Jan 3, 2022
2 parents 044be81 + 8a339bf commit 44c45d8
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/Http/Url.php
Original file line number Diff line number Diff line change
Expand Up @@ -636,6 +636,13 @@ private static function getSuffixes()
*/
private static function parse($url)
{
preg_match('/^(http|https)?\:\/\/([\w\.]+)wikipedia.org\/wiki\//', $url, $matches);
if (count($matches)) {
$wikiUrl = urldecode(trim(preg_replace('/^(http|https)?\:\/\/([\w\.]+)wikipedia.org\/wiki\//', '', $url)));
$encodeUrlWiki = urlencode($wikiUrl);
$url = $matches[0] . $encodeUrlWiki;
}

$enc_url = preg_replace_callback(
'%[^:/@?&=#]+%usD',
function ($matches) {
Expand Down

0 comments on commit 44c45d8

Please sign in to comment.