This project is archived and is in readonly mode.

#3255 ✓wontfix
Harm Aarts

Parameter :requirements in routing doesn't use implicit anchors

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

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.

Comments and changes to this ticket

  • Harm Aarts

    Harm Aarts September 24th, 2009 @ 10:23 AM

    • Tag changed from 2.3.4, regular, resources, routing to 2.3.4, expressions, regular, resources, routing
  • Andrew White

    Andrew White July 4th, 2010 @ 08:27 AM

    • 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.

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href=""></a>