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

Correct behavior of basename? #404

Closed
mindjuice opened this issue Jan 7, 2017 · 3 comments
Closed

Correct behavior of basename? #404

mindjuice opened this issue Jan 7, 2017 · 3 comments

Comments

@mindjuice
Copy link
Contributor

I'm using createBrowserHistory directly without react-router, and I tried setting the basename property. This worked, and prefixed the URLs I pushed with the right path.

However, I was expecting that history would also remove the prefix when handing back the current location to me.

Am I using this feature incorrectly or is there some reason for the asymmetry in basename handling?

Thanks!

@mjackson
Copy link
Member

mjackson commented Jan 8, 2017

We currently do remove the basename prefix before giving you location objects, so yes, that is the intent. However, there aren't great tests around this, so there may be a bug.

Can you please provide some sample code? Or even better, a failing test case?

@mindjuice
Copy link
Contributor Author

Thanks for the pointer to the code. Turns out that it's because I was passing somepath instead of /somepath. Not sure if you want to consider that a bug. We could either "fix" paths that don't start with a / or perhaps issue a console warning? I can put together a PR for either option or just leave it if you prefer.

@mjackson
Copy link
Member

mjackson commented Jan 9, 2017

Hmmm, ya we should probably automatically add a / to the front of the basename if users don't have one. I'd be happy for a PR that does this :)

@mjackson mjackson closed this as completed Jan 9, 2017
@lock lock bot locked as resolved and limited conversation to collaborators Jun 5, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants