Module: Diversion::Url
- Defined in:
- lib/diversion/url.rb
Class Method Summary collapse
- .decode_url(str) ⇒ Object
- .encode_url(str) ⇒ Object
-
.escape(str) ⇒ Object
:nocov: (turns off skip lines mode).
- .unescape(str) ⇒ Object
Instance Method Summary collapse
Class Method Details
.decode_url(str) ⇒ Object
14 15 16 17 18 |
# File 'lib/diversion/url.rb', line 14 def decode_url(str) str = legacy_decode(unescape(str)) if RUBY_VERSION < "1.9" str = Base64.urlsafe_decode64(unescape(str)) if RUBY_VERSION >= "1.9" str end |
.encode_url(str) ⇒ Object
8 9 10 11 12 |
# File 'lib/diversion/url.rb', line 8 def encode_url(str) str = legacy_encode(str) if RUBY_VERSION < "1.9" str = Base64.urlsafe_encode64(str) if RUBY_VERSION >= "1.9" escape(str) end |
.escape(str) ⇒ Object
:nocov: (turns off skip lines mode)
32 33 34 |
# File 'lib/diversion/url.rb', line 32 def escape(str) str.gsub('=',',') end |
.unescape(str) ⇒ Object
36 37 38 |
# File 'lib/diversion/url.rb', line 36 def unescape(str) str.gsub(',','=') end |
Instance Method Details
#legacy_decode(str) ⇒ Object
26 27 28 |
# File 'lib/diversion/url.rb', line 26 def legacy_decode(str) Base64.decode64(str) end |
#legacy_encode(str) ⇒ Object
22 23 24 |
# File 'lib/diversion/url.rb', line 22 def legacy_encode(str) Base64.encode64(str).gsub(/\n/,"") end |