refinery / refinerycms-news

News Plugin for Refinery CMS
http://www.refinerycms.com
MIT License
121 stars 120 forks source link

Specify regex for year and month within archive route #119

Closed allspiritseve closed 11 years ago

allspiritseve commented 11 years ago

Instead of throwing an exception when a route like /news/archive/2012/whatever is accessed, Rails will return a 404 since the route won't match anymore.

Please let me know if my regex is too specific. I assumed years would be four numbers and months would be two numbers, and everything else would not match.

ugisozols commented 11 years ago

What do you think about :constraints => { :year => /\d{4}/, :month => /\d{1,2}/ } - this way month can be specified as one or two numbers (1 or 12) instead of constraining it to two numbers (01 or 12)

allspiritseve commented 11 years ago

Good call... just updated the commit.

ugisozols commented 11 years ago

Thanks @allspiritseve!