Add .asRegExp() method to return regexp for route#27
Open
simonflk wants to merge 2 commits intorcs:masterfrom
Open
Add .asRegExp() method to return regexp for route#27simonflk wants to merge 2 commits intorcs:masterfrom
.asRegExp() method to return regexp for route#27simonflk wants to merge 2 commits intorcs:masterfrom
Conversation
Owner
|
I'm glad you find this useful! I like this. It makes sense, it makes it easier to use in more environments, and it hadn't occured to me how useful hat might be. I am a little bit apprehensive, however, because I'm not entirely sure that this is an API that continues to make sense if a candidate for specifying query parameters ever works for this library, since I'm not sure that a regex will still be the solution. (Extracting query parameters, and specifying them, is a common request.) That said: If it comes down to that, it would also be a reason to bump a major version if it couldn't be supported, and that's not the end of the world. Thoughts? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I'm using
route-parserin my react app, and it's working great, thank you!And my local dev server is serving 2 single-page apps using connect-history-api-fallback to determine which one to serve based on the URL.
Thus far I've manually crafted a regexp, then moved on to writing my own route-parser route -> regexp parser, and quickly decided that was a bit silly since route-parser can give me the regular expressions.
So here I am with a PR to expose the regexp on the route.
I'm interested to know what your thoughts on this are. Personally I'm happy to continue using the regexp visitor in my code, but I'd feel better knowing that was stable/documented. I'm happy to submit a PR for docs instead.
Another solution would be to modify connect-history-api-fallback to accept a function in place of a regexp. But I'm not a direct consumer of that module. Rather I'm using webpack-dev-server, which uses that under the hood.