Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix basePath handling #1421

Merged
merged 2 commits into from
Aug 10, 2015
Merged

Fix basePath handling #1421

merged 2 commits into from
Aug 10, 2015

Conversation

akrabat
Copy link
Member

@akrabat akrabat commented Aug 10, 2015

This PR fixes two issues:

  • The basePath isn't cleared when calling withPath('/bar')
  • __toString doesn't take basePath into account every time, which results in an incorrect URI being returned in a specific situation. (test included)

If the new path starts with a /, then it is absolute and so the base path needs to be cleared.
This occurs via createFromEnvironment when index.php is in a subdirectory as we create a
URI that has a base path and a blank path.

Casting to string needs to always include the concatenation of basePath and path.
@akrabat akrabat added this to the 3.0.0 Beta 2 milestone Aug 10, 2015
silentworks added a commit that referenced this pull request Aug 10, 2015
@silentworks silentworks merged commit b3e31e9 into slimphp:3.x Aug 10, 2015
if (!$authority && substr($path, 0, 2) === '//') {
$path = '/' . ltrim($path, '/');
}
$path = $basePath . '/' . ltrim($path, '/');
Copy link
Contributor

Choose a reason for hiding this comment

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

There are two spaces after the first '/'.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants