Instead of using some hacky regexes, just use wfParseUrl() in WikiMap::getDisplayName...
authorRoan Kattouw <catrope@users.mediawiki.org>
Fri, 12 Aug 2011 19:19:34 +0000 (19:19 +0000)
committerRoan Kattouw <catrope@users.mediawiki.org>
Fri, 12 Aug 2011 19:19:34 +0000 (19:19 +0000)
includes/WikiMap.php

index ec0a4ab..545e6a3 100644 (file)
@@ -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;
+               }
        }
 
        /**