diff --git a/lib/slug.rb b/lib/slug.rb index 86025079c5f..89e18a9051f 100644 --- a/lib/slug.rb +++ b/lib/slug.rb @@ -6,27 +6,7 @@ module Slug def self.for(string) - str = string.dup.strip.downcase - - # The characters we want to replace with a hyphen - str.tr!("·/_,:;.", "\-") - - # Convert to ASCII or remove if transliteration is unknown. - str = ActiveSupport::Inflector.transliterate(str, '') - - # Remove everything except alphanumberic, space, and hyphen characters. - str.gsub!(/[^a-z0-9 -]/, '') - - # Replace multiple spaces with one hyphen. - str.gsub!(/\s+/, '-') - - # Replace multiple hyphens with one hyphen. - str.gsub!(/\-+/, '-') - - # Remove leading and trailing hyphens - str.gsub!(/^-|-$/, '') - - str + string.parameterize end end diff --git a/spec/components/slug_spec.rb b/spec/components/slug_spec.rb index 44bd1177e8c..1ed7c4180c7 100644 --- a/spec/components/slug_spec.rb +++ b/spec/components/slug_spec.rb @@ -13,8 +13,8 @@ describe Slug do Slug.for('àllo').should == 'allo' end - it 'removes symbols' do - Slug.for('evil#trout').should == 'eviltrout' + it 'replaces symbols' do + Slug.for('evil#trout').should == 'evil-trout' end it 'handles a.b.c properly' do