Anchors are now properly handled within getLink()
authorAlexander Ebert <ebert@woltlab.com>
Fri, 16 Mar 2012 15:30:52 +0000 (16:30 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Fri, 16 Mar 2012 15:30:52 +0000 (16:30 +0100)
Fixes #523

wcfsetup/install/files/lib/system/request/LinkHandler.class.php

index 459becdc463387f869c48b1c6d0fdbc5e694aca4..6b21e65611cbfdf03da30326e95e5208aa389ba0 100644 (file)
@@ -25,6 +25,7 @@ class LinkHandler extends SingletonFactory {
         */
        public function getLink($controller = null, array $parameters = array(), $url = '') {
                $abbreviation = 'wcf';
+               $anchor = '';
                $isRaw = false;
                if (isset($parameters['application'])) {
                        $abbreviation = $parameters['application'];
@@ -35,6 +36,12 @@ class LinkHandler extends SingletonFactory {
                        unset($parameters['isRaw']);
                }
                
+               // remove anchor before parsing
+               if (($pos = strpos($url, '#')) !== false) {
+                       $anchor = substr($url, $pos);
+                       $url = substr($url, 0, $pos);
+               }
+               
                // build route
                if ($controller !== null) {
                        // handle object
@@ -84,6 +91,9 @@ class LinkHandler extends SingletonFactory {
                        $url = $application->domainName . $application->domainPath . $url;
                }
                
+               // append previously removed anchor
+               $url .= $anchor;
+               
                return $url;
        }
 }