Module: Rack::Utils
- Defined in:
- lib/sinatra_opal_patches.rb
Class Method Summary collapse
Class Method Details
.parse_cookies(env) ⇒ Object
72 73 74 |
# File 'lib/sinatra_opal_patches.rb', line 72 def (env) (env[Rack::HTTP_COOKIE]) end |
.parse_cookies_header(value) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/sinatra_opal_patches.rb', line 47 def (value) return {} if value.nil? value.split(/; */n).each_with_object({}) do |, | next if .empty? key, val = .split('=', 2) next if key.nil? decoded = if val.nil? nil else begin # decodeURIComponent semantics: decode every # percent-encoded octet but DO NOT touch literal `+`. # Cookies are not form-encoded, so the form-data # convention of mapping `+` to space does not apply. ::CGI.unescapeURIComponent(val) rescue ::StandardError val end end [key] = decoded unless .key?(key) end end |