Skip to content

Commit 44c45d8

Browse files
authored
Merge pull request #464 from AleksandrPanarin/wikipedia-url-encode
Added encoding of Wikipedia urls
2 parents 044be81 + 8a339bf commit 44c45d8

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/Http/Url.php

+7
Original file line numberDiff line numberDiff line change
@@ -636,6 +636,13 @@ private static function getSuffixes()
636636
*/
637637
private static function parse($url)
638638
{
639+
preg_match('/^(http|https)?\:\/\/([\w\.]+)wikipedia.org\/wiki\//', $url, $matches);
640+
if (count($matches)) {
641+
$wikiUrl = urldecode(trim(preg_replace('/^(http|https)?\:\/\/([\w\.]+)wikipedia.org\/wiki\//', '', $url)));
642+
$encodeUrlWiki = urlencode($wikiUrl);
643+
$url = $matches[0] . $encodeUrlWiki;
644+
}
645+
639646
$enc_url = preg_replace_callback(
640647
'%[^:/@?&=#]+%usD',
641648
function ($matches) {

0 commit comments

Comments
 (0)