Skip to content

Commit

Permalink
Added encoding of Wikipedia urls
Browse files Browse the repository at this point in the history
  • Loading branch information
AleksandrPanarin committed Dec 27, 2021
1 parent 044be81 commit 8a339bf
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 8a339bf

Please sign in to comment.