Simplified character replacement.

This commit is contained in:
Dan Neumann 2013-02-06 20:56:40 -06:00
parent 0489df0e35
commit d9a0ad7a98
1 changed files with 2 additions and 6 deletions

View File

@ -12,13 +12,9 @@ module Slug
str.downcase!
from = "àáäâèéëêìíïîòóöôùúüûñç·/_,:;."
to = "aaaaeeeeiiiioooouuuunc-------"
to = "aaaaeeeeiiiioooouuuunc\-"
idx = 0
from.each_char do |c|
str.gsub!(c, to[idx])
idx += 1
end
str.tr!(from, to)
str.gsub!(/[^a-z0-9 -]/, '')
str.gsub!(/\s+/, '-')