Module: SimpleOAuth::Encoding
- Included in:
- Header
- Defined in:
- lib/simple_oauth/encoding.rb
Overview
OAuth percent-encoding utilities
Provides methods for encoding and decoding values according to the OAuth specification. These methods can be used as module functions or extended into a class.
Constant Summary collapse
- UNRESERVED_CHARS =
Characters that don't need to be escaped per OAuth spec
/[^a-z0-9\-._~]/i
Instance Method Summary collapse
-
#escape(value) ⇒ String
(also: #encode)
Percent-encodes a value according to OAuth specification.
-
#unescape(value) ⇒ String
(also: #decode)
Decodes a percent-encoded value.
Instance Method Details
#escape(value) ⇒ String Also known as: encode
Percent-encodes a value according to OAuth specification
30 31 32 |
# File 'lib/simple_oauth/encoding.rb', line 30 def escape(value) URI::RFC2396_PARSER.escape(value.to_s, UNRESERVED_CHARS) end |
#unescape(value) ⇒ String Also known as: decode
Decodes a percent-encoded value
43 44 45 |
# File 'lib/simple_oauth/encoding.rb', line 43 def unescape(value) URI::RFC2396_PARSER.unescape(value.to_s) end |