Skip to content

Commit

Permalink
Made strip_non_ascii first stip diacritics to avoid blowing away too …
Browse files Browse the repository at this point in the history
…many

letters.
  • Loading branch information
Norman Clarke committed Feb 4, 2009
1 parent 852f432 commit 391186a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/friendly_id/slug.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def strip_diacritics(string)

# Remove non-ascii characters from the string.
def strip_non_ascii(string)
string.gsub(/[^a-z0-9]+/i, ' ')
strip_diacritics(string).gsub(/[^a-z0-9]+/i, ' ')
end

private
Expand Down
9 changes: 5 additions & 4 deletions test/sluggable_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ class SluggableTest < Test::Unit::TestCase

def setup
Post.friendly_id_options[:max_length] = FriendlyId::ClassMethods::DEFAULT_FRIENDLY_ID_OPTIONS[:max_length]
Post.friendly_id_options[:strip_non_ascii] = false
Post.friendly_id_options[:strip_diacritics] = false
end

def test_should_allow_for_identical_slug_names_between_sluggable_types
Expand Down Expand Up @@ -100,14 +102,13 @@ def test_should_strip_diactics_from_slug_if_configured_to_do_so
end

def test_should_not_strip_diactics_from_slug_unless_configured_to_do_so
Post.friendly_id_options[:strip_diacritics] = false
@post = Post.new(:name => "¡FELIZ AÑO!")
assert_equal "feliz-año", @post.slug_text
end
def test_should_strip_symbols

def test_should_convert_to_ascii
Post.friendly_id_options[:strip_non_ascii] = true
@post = Post.new(:name => "►►17” computer monitor ◄◄")
@post = Post.new(:name => "17” cômpütér mõnitor")
assert_equal '17-computer-monitor', @post.slug_text
end

Expand Down

0 comments on commit 391186a

Please sign in to comment.