]> source.dussan.org Git - nextcloud-server.git/commitdiff
Match \OC_Helper::linkToPublic() to new links and fit unittests
authorkondou <kondou@ts.unde.re>
Thu, 4 Sep 2014 17:51:38 +0000 (19:51 +0200)
committerkondou <kondou@ts.unde.re>
Thu, 4 Sep 2014 18:44:50 +0000 (20:44 +0200)
lib/private/helper.php
tests/lib/helper.php

index 7c1edd1b05880f4a5f7e3ce303b0262ba6b441eb..f696b5a890020ec46466897478b624b8704a3379 100644 (file)
@@ -129,12 +129,12 @@ class OC_Helper {
         * Returns a absolute url to the given service.
         */
        public static function linkToPublic($service, $add_slash = false) {
-               return OC::$server->getURLGenerator()->getAbsoluteURL(
-                       self::linkTo(
-                               '', 'public.php') . '?service=' . $service
-                               . (($add_slash && $service[strlen($service) - 1] != '/') ? '/' : ''
-                       )
-               );
+               if ($service === 'files') {
+                       $url = OC::$server->getURLGenerator()->getAbsoluteURL('/s');
+               } else {
+                       $url = OC::$server->getURLGenerator()->getAbsoluteURL(self::linkTo('', 'public.php').'?service='.$service);
+               }
+               return $url . (($add_slash && $service[strlen($service) - 1] != '/') ? '/' : '');
        }
 
        /**
index 20b8571b91d96dd680bb4cc0fe702486ac5a5758..cb342e295ba4774f7d67f56fbfb8cbf06e92c79a 100644 (file)
@@ -443,15 +443,33 @@ class Test_Helper extends PHPUnit_Framework_TestCase {
        public function testLinkToPublic() {
                \OC::$WEBROOT = '';
                $result = \OC_Helper::linkToPublic('files');
-               $this->assertEquals('http://localhost/public.php?service=files', $result);
+               $this->assertEquals('http://localhost/s', $result);
                $result = \OC_Helper::linkToPublic('files', false);
-               $this->assertEquals('http://localhost/public.php?service=files', $result);
+               $this->assertEquals('http://localhost/s', $result);
+               $result = \OC_Helper::linkToPublic('files', true);
+               $this->assertEquals('http://localhost/s/', $result);
+
+               $result = \OC_Helper::linkToPublic('other');
+               $this->assertEquals('http://localhost/public.php?service=other', $result);
+               $result = \OC_Helper::linkToPublic('other', false);
+               $this->assertEquals('http://localhost/public.php?service=other', $result);
+               $result = \OC_Helper::linkToPublic('other', true);
+               $this->assertEquals('http://localhost/public.php?service=other/', $result);
 
                \OC::$WEBROOT = '/owncloud';
                $result = \OC_Helper::linkToPublic('files');
-               $this->assertEquals('http://localhost/owncloud/public.php?service=files', $result);
+               $this->assertEquals('http://localhost/owncloud/s', $result);
                $result = \OC_Helper::linkToPublic('files', false);
-               $this->assertEquals('http://localhost/owncloud/public.php?service=files', $result);
+               $this->assertEquals('http://localhost/owncloud/s', $result);
+               $result = \OC_Helper::linkToPublic('files', true);
+               $this->assertEquals('http://localhost/owncloud/s/', $result);
+
+               $result = \OC_Helper::linkToPublic('other');
+               $this->assertEquals('http://localhost/owncloud/public.php?service=other', $result);
+               $result = \OC_Helper::linkToPublic('other', false);
+               $this->assertEquals('http://localhost/owncloud/public.php?service=other', $result);
+               $result = \OC_Helper::linkToPublic('other', true);
+               $this->assertEquals('http://localhost/owncloud/public.php?service=other/', $result);
        }
 
        /**