-
-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
Path vs path + query #413
Comments
Perhaps some of the authors of this code should level up on the RFC and pay a little bit more attention to the names of things and what they are returning! I can work on this, or if you'd like, please submit a pull request with whatever changes need to be made. |
CurrentPath might be the wrong name for the mixin itself as issues concerning ways to change only parts of the URL keep popping up. Both #378 and #394 could use something like Thoughts? |
the use-case for the CurrentPath mixin came from two things for me personally:
But its not designed to ever update the path. Maybe it should have some methods that mutate it? Seems nice. |
The RFC does not have a word for
In general, the node API follows HTML5's URL API, though, admittedly, they differ on this point. It's also worth noting that node's URL API and @sbrekken Please don't think I didn't think long and hard before I chose these names! :) It's just that there are competing "standards" out there for the same thing. |
Actually, I should correct myself: node's URL API more closely resembles Edit: Also note that |
@mjackson, |
@kharin Thanks for the reference, tho I'd really like to find one in common use in JavaScript somewhere. |
@mjackson I don't really see the benefit of ever letting My suggestion is to never include |
@sbrekken There is a substantial benefit from being able to refer to If you'd like, I'd be open to using |
@mjackson Naming aside, I think my initial example illustrates the ambiguity of the API where |
@simenbrekken After a lot of thinking about this I still feel like the way we're currently using the words If you still feel like something needs to be changed, please continue the conversation. But until we have a more concrete example of some inconsistency in the API, I'm going to close. Thanks for bringing this to our attention! :) |
@mjackson I still feel something needs to be changed. Look at #522, having to do: if (Path.withoutQuery(path) === Path.withoutQuery(prevPath)) {
return false;
} Here the query is being stripped from a complete path twice in one statement. And at the same time you have access to This leads me to think that the current state API only gives you either the entire car or just the back half. But what if you have some business in the front? That's not currently possible without either manually importing the private |
@simenbrekken One thing we could do to make that statement cleaner would be to provide
The current
For all of the use cases I've seen that API has been sufficient, except for the internal router code you posted above which we could fix by adding |
@mjackson While I'm still a bit on the fence on naming, I'm more than happy with |
I agree with @simenbrekken. There are places where I'd like to construct a path to send to this.transitionTo(this.getPath() + "/edit"); This would provide some nice reusability and easier maintenance than passing in a route name as a prop to the component. If you have query params attached to the path you have to either strip them or abandon the approach. I agree that the API is inconsistent in regard to @simenbrekken's comments. However, even if it wasn't, having the ability to access both halves of the car (if I may borrow some language) would be convenient. |
Right now everywhere in react-router the term "path" is used it refers to the anything after the hostname part of an URI. However RFC3986 specifically states:
I just ran into this today where I was trying to add a query string to an existing URL by means of
transitionTo
:This should produce the following URLs:
But the last URL becomes:
This is probably just a regression (it worked before 0.5) but I still think react-router should adhere to the RFC when it comes to words like "path", "query" and "url".
The text was updated successfully, but these errors were encountered: