File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -11,14 +11,11 @@ def self.for(string)
1111 str . gsub! ( /^\s +|\s +$/ , '' )
1212 str . downcase!
1313
14- from = "àáäâèéëêìíïîòóöôùúüûñç·/_,:;."
15- to = "aaaaeeeeiiiioooouuuunc-------"
16-
17- idx = 0
18- from . each_char do |c |
19- str . gsub! ( c , to [ idx ] )
20- idx += 1
21- end
14+ # The characters we want to replace with a hyphen
15+ str . tr! ( "·/_,:;." , "\- " )
16+
17+ # Convert to ASCII or remove if transliteration is unknown.
18+ str = ActiveSupport ::Inflector . transliterate ( str , '' )
2219
2320 str . gsub! ( /[^a-z0-9 -]/ , '' )
2421 str . gsub! ( /\s +/ , '-' )
Original file line number Diff line number Diff line change 3535 Slug . for ( "...hello" ) . should == "hello"
3636 end
3737
38+ it 'handles our initial transliteration' do
39+ from = "àáäâčďèéëěêìíïîľĺňòóöôŕřšťůùúüûýžñç"
40+ to = "aaaacdeeeeeiiiillnoooorrstuuuuuyznc"
41+ Slug . for ( from ) . should == to
42+ end
43+
3844end
3945
You can’t perform that action at this time.
0 commit comments