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

Allow + and ? as path_spec wildcards #36

Closed
wants to merge 2 commits into from
Closed

Allow + and ? as path_spec wildcards #36

wants to merge 2 commits into from

Conversation

ghost
Copy link

@ghost ghost commented Mar 5, 2012

It'd be nice to have + (at least one) and ? (at most one) as additional wildcard characters for routing. Implementation is in a separate commit.

@bernd
Copy link
Contributor

bernd commented Mar 7, 2012

+1 I think that is useful.

@seancribbs
Copy link
Member

My main concern with '+' and '?' is that they are valid characters in a URI. Does this potentially confuse the user?

@ghost
Copy link
Author

ghost commented Mar 7, 2012

So is * 😁 ? should be okay as it's the delimiter between request URI and query. But you're right, it can be confusing.

Would it be an option to generally treat string segments as pure strings and use symbols for everything that has a meaning for routing? That would mean using :*, :+ and :"?" as wildcards.

@seancribbs
Copy link
Member

@lgierth You have a point about * being a valid URI character.

Also the question becomes, and what point are we reimplementing regular expressions or Rails' router? This deserves pondering.

FWIW you can also implement + and ? in terms of other rules, e.g.

add ["foo", '+'], AtLeastOneResource
add ["bar", '?'], AtMostOneResource

becomes

add ["foo", :one, "*"], AtLeastOneResource
add ["bar", :one],      AtMostOneResource
add ["bar"],            AtMostOneResource

Does the extra brevity and the lack of a mandatory binding help? I feel ambivalent about it without a strong use-case.

@ghost
Copy link
Author

ghost commented Mar 7, 2012

To be honest, I didn't even think of simply adding the Resource with two different routes. That's beautiful! So please consider the PR obsolete.

Using :* instead of "*" might still make sense though, as the current route API doesn't clearly communicate which parameters have real meaning to it.

@ghost ghost closed this Mar 7, 2012
@seancribbs
Copy link
Member

@lgierth Thanks, I think turning it into a symbol makes sense. I'll need to insert deprecation notices and the like (to be nice).

This pull request was closed.
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.

2 participants