Browse Source

Drop the "index" part of URLs

Closes #347. Thanks @Robby-
Daniel Rudolf 9 năm trước cách đây
mục cha
commit
1b3ef7516d
1 tập tin đã thay đổi với 11 bổ sung2 xóa
  1. 11 2
      lib/Pico.php

+ 11 - 2
lib/Pico.php

@@ -1387,9 +1387,18 @@ class Pico
                 . (is_object($queryData) ? get_class($queryData) : gettype($queryData)) . ' given'
                 . (is_object($queryData) ? get_class($queryData) : gettype($queryData)) . ' given'
             );
             );
         }
         }
+
+        // drop "index"
+        if ($page === 'index') {
+            $page = '';
+        } elseif (($pagePathLength = strrpos($page, '/')) !== false) {
+            if (substr($page, $pagePathLength + 1) === 'index') {
+                $page = substr($page, 0, $pagePathLength);
+            }
+        }
+
         if (!empty($queryData)) {
         if (!empty($queryData)) {
-            $page = !empty($page) ? $page : 'index';
-            $queryData = $this->isUrlRewritingEnabled() ? '?' . $queryData : '&' . $queryData;
+            $queryData = ($this->isUrlRewritingEnabled() || empty($page)) ? '?' . $queryData : '&' . $queryData;
         }
         }
 
 
         if (empty($page)) {
         if (empty($page)) {