1
0
Fork 0
forked from OpenNeo/impress

remove non-alphanumeric chars from item pretty urls

mainly because they were causing the router to freak out when they
contained periods, because that looks like a format, e.g. show.html
This commit is contained in:
Emi Matchu 2011-05-20 19:50:06 -04:00
parent fa46a03c91
commit 183430adb6
2 changed files with 3 additions and 2 deletions

View file

@ -156,8 +156,9 @@ class Item < ActiveRecord::Base
}
end
URL_CHAR_BLACKLIST = /[^a-z0-9\-]/i
def name_for_url
name.downcase.gsub(' ', '-')
name.downcase.gsub(' ', '-').gsub(URL_CHAR_BLACKLIST, '')
end
def to_param

View file

@ -126,7 +126,7 @@ function Wardrobe() {
}
function getNameForSlug() {
return item.name.toLowerCase().replace(/ /g, '-');
return item.name.toLowerCase().replace(/ /g, '-').replace(/[^a-z0-9\-]/i, '');
}
function getSlug() {