From: Roan Kattouw Date: Fri, 12 Aug 2011 19:19:34 +0000 (+0000) Subject: Instead of using some hacky regexes, just use wfParseUrl() in WikiMap::getDisplayName... X-Git-Tag: 1.31.0-rc.0~28309 X-Git-Url: http://git.cyclocoop.org/ecrire?a=commitdiff_plain;h=d0d89f42974030ec986b53ac38fe3aadefebf3df;p=lhc%2Fweb%2Fwiklou.git Instead of using some hacky regexes, just use wfParseUrl() in WikiMap::getDisplayName(). This should make protocol-relative URLs behave correctly as well, and fix bug 29965 --- diff --git a/includes/WikiMap.php b/includes/WikiMap.php index ec0a4abbad..545e6a35eb 100644 --- a/includes/WikiMap.php +++ b/includes/WikiMap.php @@ -129,11 +129,13 @@ class WikiReference { */ public function getDisplayName() { $url = $this->getUrl( '' ); - $url = preg_replace( '!^https?://!', '', $url ); - $url = preg_replace( '!/index\.php(\?title=|/)$!', '/', $url ); - $url = preg_replace( '!/wiki/$!', '/', $url ); - $url = preg_replace( '!/$!', '', $url ); - return $url; + $parsed = wfParseUrl( $url ); + if ( $parsed ) { + return $parsed['host']; + } else { + // Invalid URL. There's no sane thing to do here, so just return it + return $url; + } } /**