Skip to content

Commit

Permalink
BUGFIX: align validation and slug generation regexes so they don't re…
Browse files Browse the repository at this point in the history
…ly on character classes
  • Loading branch information
bkoski committed Jun 25, 2010
1 parent afdde67 commit 6abb528
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/slug/slug.rb
Expand Up @@ -78,7 +78,7 @@ def normalize_slug
s = ActiveSupport::Multibyte.proxy_class.new(self[self.slug_column]).normalize(:kc)
s.downcase!
s.strip!
s.gsub!(/[^\w\s-]/, '') # Remove non-word characters
s.gsub!(/[^a-z0-9\s-]/, '') # Remove non-word characters
s.gsub!(/\s+/, '-') # Convert whitespaces to dashes
s.gsub!(/-\z/, '') # Remove trailing dashes
s.gsub!(/-+/, '-') # get rid of double-dashes
Expand Down
2 changes: 1 addition & 1 deletion test/test_slug.rb
Expand Up @@ -142,7 +142,7 @@ def setup
end

should "should remove punctuation" do
@article.headline = 'abc!@#$%^&*•¶§∞¢££¡¿()><?"":;][]\.,/'
@article.headline = 'abc!@#$%^&*•¶§∞¢££¡¿()><?""\':;][]\.,/'
@article.save!
assert_match 'abc', @article.slug
end
Expand Down

0 comments on commit 6abb528

Please sign in to comment.