Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Converting /to slash. #50

Merged
merged 1 commit into from

2 participants

@dblock

It's also a slash, so it should become one.

@rsl
Owner

good find as usual :D

@rsl rsl merged commit c739fed into rsl:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on May 4, 2012
  1. @dblock

    Converting /to slash.

    dblock authored
This page is out of date. Refresh to see the latest.
View
6 lib/stringex/string_extensions.rb
@@ -40,7 +40,7 @@ def to_url(options = {})
end
def limit(lim = nil)
- lim.nil? ? self : self[0...lim]
+ lim.nil? ? self : self[0...lim]
end
# Performs multiple text manipulations. Essentially a shortcut for typing them all. View source
@@ -173,7 +173,7 @@ def convert_misc_characters(options = {})
dummy.gsub!(found, replaced)
end
# Back to normal rules
- misc_characters =
+ misc_characters =
{
/\s*&\s*/ => "and",
/\s*#/ => "number",
@@ -188,7 +188,7 @@ def convert_misc_characters(options = {})
/\s*\+\s*/ => "plus",
/\s\s*/ => "degrees"
}
- misc_characters[/\s*(\\|\/)\s*/] = 'slash' unless options[:allow_slash]
+ misc_characters[/\s*(\\|\/|/)\s*/] = 'slash' unless options[:allow_slash]
misc_characters.each do |found, replaced|
replaced = " #{replaced} " unless replaced =~ /\\1/
dummy.gsub!(found, replaced)
View
16 test/string_extensions_test.rb
@@ -57,18 +57,20 @@ def test_to_url
"one-fourth-pound-with-cheese",
"Will's Ferrel" =>
"wills-ferrel",
- "Капитал" =>
+ "Капитал" =>
"kapital",
- "Ελλάδα" =>
+ "Ελλάδα" =>
"ellada",
- "中文" =>
+ "中文" =>
"zhong-wen",
- "Paul Cézanne" =>
+ "Paul Cézanne" =>
"paul-cezanne",
- "21'17ʼ51" =>
+ "21'17ʼ51" =>
"21-17-51",
- "ITCZ 1 (21°17ʼ51.78”N / 89°35ʼ28.18”O / 26-04-08 / 09:00 am)" =>
- "itcz-1-21-degrees-17-51-dot-78-n-slash-89-degrees-35-28-dot-18-o-slash-26-04-08-slash-09-00-am"
+ "ITCZ 1 (21°17ʼ51.78”N / 89°35ʼ28.18”O / 26-04-08 / 09:00 am)" =>
+ "itcz-1-21-degrees-17-51-dot-78-n-slash-89-degrees-35-28-dot-18-o-slash-26-04-08-slash-09-00-am",
+ "" =>
+ "slash"
}.each do |html, plain|
assert_equal plain, html.to_url
end
Something went wrong with that request. Please try again.