Skip to content

Commit

Permalink
Drop the "index" part of URLs
Browse files Browse the repository at this point in the history
Closes #347. Thanks @Robby-
  • Loading branch information
PhrozenByte committed Apr 23, 2016
1 parent a119122 commit 1b3ef75
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions lib/Pico.php
Original file line number Diff line number Diff line change
Expand Up @@ -1387,9 +1387,18 @@ public function getPageUrl($page, $queryData = null)
. (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)) {
$page = !empty($page) ? $page : 'index';
$queryData = $this->isUrlRewritingEnabled() ? '?' . $queryData : '&' . $queryData;
$queryData = ($this->isUrlRewritingEnabled() || empty($page)) ? '?' . $queryData : '&' . $queryData;
}

if (empty($page)) {
Expand Down

3 comments on commit 1b3ef75

@mayamcdougall
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait, that was an intentional behavior? 😆

I figured it was just a side-effect of some other url-determining code.

@PhrozenByte
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, this wasn't intended, more some sort of "didn't care about it". 😉 Line 1391 was about something else (a edge case for custom themes).

@mayamcdougall
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol 👍

Please sign in to comment.