Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

Parameter :requirements in routing doesn't use implicit anchors

#3255

Consider the following route:
map.detail "subscription_plans/:provider/:plan", :action =>
"detail", :requirements => {:plan => /[^ ]+/}

I want this route to match any string without a space character. So
"Telfort-100" matches "Telfort 100" does not. This however does not work. It matches both.

I believed this to be correct but it's not. Including anchors ('\A'
'$' etc) is not allowed and the docs seem to suggest they are implicit.

Reported by Harm Aarts · September 24th, 2009 @ 10:22 AM

State: wontfix
Milestone: none
Assigned to: Andrew White Andrew White
Importance: Low

Activity

  1. Harm Aarts
    Harm Aarts
    • Tag changed from 2.3.4, regular, resources, routing to 2.3.4, expressions, regular, resources, routing

    September 24th, 2009 @ 10:23 AM

  2. Andrew White
    Andrew White
    • Assigned user set to Andrew White
    • State changed from new to wontfix
    • Importance changed from to Low

    The problem you're having is that the space is url encoded as %20 or + when the router compares the regexp. If you change your requirement to explicitly state what is allowed then your route will work. These regexps /[-_a-zA-Z0-9]+/ or /\w+/ both prevent spaces in the url.

    July 4th, 2010 @ 08:27 AM