Simplified character replacement.
This commit is contained in:
parent
0489df0e35
commit
d9a0ad7a98
|
@ -12,13 +12,9 @@ module Slug
|
||||||
str.downcase!
|
str.downcase!
|
||||||
|
|
||||||
from = "àáäâèéëêìíïîòóöôùúüûñç·/_,:;."
|
from = "àáäâèéëêìíïîòóöôùúüûñç·/_,:;."
|
||||||
to = "aaaaeeeeiiiioooouuuunc-------"
|
to = "aaaaeeeeiiiioooouuuunc\-"
|
||||||
|
|
||||||
idx = 0
|
str.tr!(from, to)
|
||||||
from.each_char do |c|
|
|
||||||
str.gsub!(c, to[idx])
|
|
||||||
idx += 1
|
|
||||||
end
|
|
||||||
|
|
||||||
str.gsub!(/[^a-z0-9 -]/, '')
|
str.gsub!(/[^a-z0-9 -]/, '')
|
||||||
str.gsub!(/\s+/, '-')
|
str.gsub!(/\s+/, '-')
|
||||||
|
|
Loading…
Reference in New Issue