# URL with "." which is part of a parameter, not an extension!

**URL:** <https://www.ruby-forum.com/t/url-with-which-is-part-of-a-parameter-not-an-extension/126465>\
**Category:** Rails\
**Created:** [January 18, 2008, 2:58pm UTC](https://www.ruby-forum.com/t/url-with-which-is-part-of-a-parameter-not-an-extension/126465 "2008-01-18T14:58:05Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![nauhaie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/3ab097/32.png) [@nauhaie](https://www.ruby-forum.com/u/nauhaie)\
**Post date:** [January 18, 2008, 2:58pm UTC](https://www.ruby-forum.com/t/url-with-which-is-part-of-a-parameter-not-an-extension/126465/1 "2008-01-18T14:58:05Z")

</div>

Hi, all!

Here’s the problem! I have a page which is supposed to display the  
profile of a member given it’s username. For example:

[http://www](http://www).\*\*\*.com/users/ahmed.hk

Everything worked fine until some guy got the wonderfull idea to put a  
“.” in his username, and then, all I get is a 404 error, for rails takes  
.hk as an extension!

Any idea how to make a route ignore “.”'s ?

Thanks a lot!

Nauhaie

---

<div class="post-metadata">

**Author:** ![nauhaie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/3ab097/32.png) [@nauhaie](https://www.ruby-forum.com/u/nauhaie)\
**Post date:** [January 18, 2008, 3:46pm UTC](https://www.ruby-forum.com/t/url-with-which-is-part-of-a-parameter-not-an-extension/126465/2 "2008-01-18T15:46:32Z")

</div>

You can restrict what the usernames can include in the model using  
validates\_format\_of

OR

if you want to keep funky usernames, then use the wonderful  
permalink\_fu plugin to add a permalink attribute to your model. Then,  
your map your routes to the permalink instead of the username. It’ll  
take you 10 minutes, and do all of the hard regular expression work  
for you 😉

Sudara

On Jan 18, 3:33 pm, Damaris F. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![nauhaie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/3ab097/32.png) [@nauhaie](https://www.ruby-forum.com/u/nauhaie)\
**Post date:** [January 18, 2008, 3:33pm UTC](https://www.ruby-forum.com/t/url-with-which-is-part-of-a-parameter-not-an-extension/126465/3 "2008-01-18T15:33:36Z")

</div>

You will have to code the names by yourself (and decode them when they  
reach the controller); afar there is no way to do such ignorement.

Nauhaie N. wrote:

> Hi, all!
> 
> Here’s the problem! I have a page which is supposed to display the  
> profile of a member given it’s username. For example:
> 
> [http://www](http://www).\*\*\*.com/users/ahmed.hk
> 
> Everything worked fine until some guy got the wonderfull idea to put a  
> “.” in his username, and then, all I get is a 404 error, for rails takes  
> .hk as an extension!
> 
> Any idea how to make a route ignore “.”'s ?
> 
> Thanks a lot!
> 
> Nauhaie

---

<div class="post-metadata">

**Author:** ![nauhaie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/3ab097/32.png) [@nauhaie](https://www.ruby-forum.com/u/nauhaie)\
**Post date:** [January 19, 2008, 3:37am UTC](https://www.ruby-forum.com/t/url-with-which-is-part-of-a-parameter-not-an-extension/126465/4 "2008-01-19T03:37:26Z")

</div>

You can use the regexp to accept “.” as a parameter.

The most simple way is:

map.connect ‘/users/:name’, :controller =\> ‘users’, :action =\> ‘xx’,  
:name  
=\> /.\*/

On Jan 18, 2008 9:58 PM, Nauhaie N. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![nauhaie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/3ab097/32.png) [@nauhaie](https://www.ruby-forum.com/u/nauhaie)\
**Post date:** [January 19, 2008, 3:35pm UTC](https://www.ruby-forum.com/t/url-with-which-is-part-of-a-parameter-not-an-extension/126465/5 "2008-01-19T15:35:03Z")

</div>

sishen wrote:

> map.connect ‘/users/:name’, :controller =\> ‘users’, :action =\> ‘xx’,  
> :name  
> =\> /.\*/

Impeccable! Thank you so much!

Nauhaie
