# The latest & greatest Routing (Rails Edge 4611)

**URL:** <https://www.ruby-forum.com/t/the-latest-greatest-routing-rails-edge-4611/100800>\
**Category:** Rails\
**Created:** [August 1, 2006, 6:18am UTC](https://www.ruby-forum.com/t/the-latest-greatest-routing-rails-edge-4611/100800 "2006-08-01T06:18:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![doug](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/dbc845/32.png) [@doug](https://www.ruby-forum.com/u/doug)\
**Post date:** [August 1, 2006, 6:18am UTC](https://www.ruby-forum.com/t/the-latest-greatest-routing-rails-edge-4611/100800/1 "2006-08-01T06:18:44Z")

</div>

Got a quick question regarding the latest and greatest:

module ActionController  
module Routing  
SEPARATORS = %w( / ; . , ? )

Why is period (.) one of the separators? As it stands, the new routing  
code doesn’t recognize ‘file.ext’ as the last component of a URL, which  
is sometimes defaulted to nil. See the generated code below.

I don’t know everything about URL encoding, but it seems that period  
isn’t one of should-be-escaped characters in a URL.

Thanks in advance!

Doug.

–Generated code–  
if (match =  
/\A/(user)/(login|logout|show|list)(?:/?\Z|/([^/;.,?]+)/?)\Z/.match(path))

---

<div class="post-metadata">

**Author:** ![doug](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/dbc845/32.png) [@doug](https://www.ruby-forum.com/u/doug)\
**Post date:** [August 1, 2006, 6:31am UTC](https://www.ruby-forum.com/t/the-latest-greatest-routing-rails-edge-4611/100800/2 "2006-08-01T06:31:49Z")

</div>

On Jul 31, 2006, at 9:18 PM, Doug D. wrote:

> Got a quick question regarding the latest and greatest:
> 
> module ActionController  
> module Routing  
> SEPARATORS = %w( / ; . , ? )
> 
> Why is period (.) one of the separators? As it stands, the new routing  
> code doesn’t recognize ‘file.ext’ as the last component of a URL,  
> which  
> is sometimes defaulted to nil. See the generated code below.

An extension is the natural way to specify a resource’s mime type:  
/people/1.xml

So it’s now parameterizable:  
map.connect ‘/:controller/:id.:format’, :action =\>  
‘show’, :require =\> { :method =\> :get }

class PeopleController …  
def show  
# The :format param informs respond\_to.  
respond\_to do |wants|  
wants.html # renders the rhtml  
wants.xml { render :xml =\> @person.to\_xml }  
end  
end

GET /people/1  
GET /people/1.html  
GET /people/1.xml

jeremy

---

<div class="post-metadata">

**Author:** ![doug](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/dbc845/32.png) [@doug](https://www.ruby-forum.com/u/doug)\
**Post date:** [August 1, 2006, 5:43pm UTC](https://www.ruby-forum.com/t/the-latest-greatest-routing-rails-edge-4611/100800/3 "2006-08-01T17:43:58Z")

</div>

Thank you, Jeremy, for the clear explanation! Indeed, it’s quite a  
useful feature.

However, the implementation of it has introduced a problem: a URL that’s  
generated by the following route cannot be recognized by the same route.  
map.connect ‘/:controller/:action/:file’, :defaults =\> (:file =\> nil}  
Note that .:format isn’t specified, and then the file segment contains a  
dot, but url\_for doesn’t escape the dot.

A bug?

Doug.

Jeremy K. wrote:

> An extension is the natural way to specify a resource’s mime type:  
> /people/1.xml
> 
> So it’s now parameterizable:  
> map.connect ‘/:controller/:id.:format’, :action =\>  
> ‘show’, :require =\> { :method =\> :get }
> 
> class PeopleController …  
> def show  
> # The :format param informs respond\_to.  
> respond\_to do |wants|  
> wants.html # renders the rhtml  
> wants.xml { render :xml =\> @person.to\_xml }  
> end  
> end
> 
> GET /people/1  
> GET /people/1.html  
> GET /people/1.xml
> 
> jeremy
