Commit a5c10ed77cb25a83d509bf6107f4b50c6651346d
1 parent
341368a4
Exists in
master
and in
29 other branches
ActionItem305: don't remove leading digits in slug
Showing
2 changed files
with
7 additions
and
2 deletions
Show diff stats
lib/noosfero/core_ext/string.rb
... | ... | @@ -37,7 +37,7 @@ class String |
37 | 37 | end |
38 | 38 | |
39 | 39 | def to_slug |
40 | - transliterate.downcase.gsub(/^\d+/,'').gsub( /[^a-z0-9~\s:;+=_."'`-]/, '').gsub(/[\s:;+=_"'`-]+/, '-').gsub(/-$/, '').gsub(/^-/, '').to_s | |
40 | + transliterate.downcase.gsub(/[^a-z0-9~\s:;+=_."'`-]/, '').gsub(/[\s:;+=_"'`-]+/, '-').gsub(/-$/, '').gsub(/^-/, '').to_s | |
41 | 41 | end |
42 | 42 | |
43 | 43 | end | ... | ... |
test/unit/slug_test.rb
... | ... | @@ -7,7 +7,7 @@ class SlugTest < Test::Unit::TestCase |
7 | 7 | assert_equal 'abc', 'abc!)@(*#&@!*#*)'.to_slug |
8 | 8 | end |
9 | 9 | |
10 | - should 'turn punctuation into dashes' do | |
10 | + should 'turn punctuation into s' do | |
11 | 11 | assert_equal 'a-b-c-d-e-f', 'a:b;c+d=e_f'.to_slug |
12 | 12 | end |
13 | 13 | |
... | ... | @@ -27,4 +27,9 @@ class SlugTest < Test::Unit::TestCase |
27 | 27 | assert_equal 'a-b-c-d', 'a"b\'c`d'.to_slug |
28 | 28 | end |
29 | 29 | |
30 | + should 'not remove numbers in beginning of slug' do | |
31 | + assert_equal '3-times', '3 times'.to_slug | |
32 | + assert_equal '3x640.jpg', '3x640.jpg'.to_slug | |
33 | + end | |
34 | + | |
30 | 35 | end | ... | ... |