From d0d89f42974030ec986b53ac38fe3aadefebf3df Mon Sep 17 00:00:00 2001 From: Roan Kattouw Date: Fri, 12 Aug 2011 19:19:34 +0000 Subject: [PATCH] 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 --- includes/WikiMap.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) 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; + } } /** -- 2.20.1