瀏覽代碼

Force Pico::$requestUrl to have no leading/trailing slash

Fixes #291
Daniel Rudolf 9 年之前
父節點
當前提交
698a249d45
共有 2 個文件被更改,包括 5 次插入3 次删除
  1. 1 0
      CHANGELOG.md
  2. 4 3
      lib/Pico.php

+ 1 - 0
CHANGELOG.md

@@ -26,6 +26,7 @@ Released: -
 * [Fixed] #272: Encode URLs using `rawurlencode()` in `Pico::getPageUrl()`
 * [Fixed] #272: Encode URLs using `rawurlencode()` in `Pico::getPageUrl()`
 * [Fixed] #274: Prevent double slashes in `base_url`
 * [Fixed] #274: Prevent double slashes in `base_url`
 * [Fixed] #285: Make `index.php` work when installed as a composer dependency
 * [Fixed] #285: Make `index.php` work when installed as a composer dependency
+* [Fixed] #291: Force `Pico::$requestUrl` to have no leading/trailing slash
 ```
 ```
 
 
 ### Version 1.0.0-beta.1
 ### Version 1.0.0-beta.1

+ 4 - 3
lib/Pico.php

@@ -567,9 +567,9 @@ class Pico
      *
      *
      * We recommend you to use the `link` filter in templates to create
      * We recommend you to use the `link` filter in templates to create
      * internal links, e.g. `{{ "sub/page"|link }}` is equivalent to
      * internal links, e.g. `{{ "sub/page"|link }}` is equivalent to
-     * `{{ base_url }}sub/page`. In content files you can still use the
-     * `%base_url%` variable; e.g. `%base_url%?sub/page` will be automatically
-     * replaced accordingly.
+     * `{{ base_url }}/sub/page` and `{{ base_url }}?sub/page`, depending on
+     * enabled URL rewriting. In content files you can use the `%base_url%`
+     * variable; e.g. `%base_url%?sub/page` will be replaced accordingly.
      *
      *
      * @see    Pico::getRequestUrl()
      * @see    Pico::getRequestUrl()
      * @return void
      * @return void
@@ -587,6 +587,7 @@ class Pico
             $pathComponent = substr($pathComponent, 0, $pathComponentLength);
             $pathComponent = substr($pathComponent, 0, $pathComponentLength);
         }
         }
         $this->requestUrl = (strpos($pathComponent, '=') === false) ? rawurldecode($pathComponent) : '';
         $this->requestUrl = (strpos($pathComponent, '=') === false) ? rawurldecode($pathComponent) : '';
+        $this->requestUrl = trim($this->requestUrl, '/');
     }
     }
 
 
     /**
     /**