Skip to content

More powerful/flexible path matching #142

@mjackson

Description

@mjackson

Let's make string-based pattern matching more flexible to accommodate some of the use cases we're starting to see.

In particular, I'd like to propose we follow Sinatra's lead here and:

  • Allow ? to mean "match the previous thing 0 or 1 time"
  • Modify * to not match . since it can be excluded using ?

By just doing these two changes, we can support the following kinds of URLs:

  • /posts/:slug.?:format? (make the .html portion of a URL optional)
  • /files/*.* (get the file extension in a separate splat)
  • /archive/? (optional trailing slash)

I've already got this functionality in mach and it's working really well. I rarely (read: haven't yet needed to) use a regular expression to match on a URL path. I realize that this discussion will probably evolve to include supporting full-blown regular expressions, but I'd like to discuss that in a separate issue if people are interested.

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature-requestUsed to close PRs that haven't gone through/been accepted the Proposal process yet

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions