0

Let's say I have a URL that I want to parse, including the query string:

https://www.example.com/foo?bar=1&a[]=x&a[]=y

I would expect to be able to obtain a hash of the query string like:

{ "bar" => "1", "a" => ["x", "y"] }

How can I parse this using Opal? I looked at options like URI and even CGI from Ruby, but it seems they are unavailable.

Clearly, I could break apart this string myself (or possibly use the Addressable gem), but I would like to use some included library function instead.

Benjamin Oakes
  • 12,262
  • 12
  • 65
  • 83

1 Answers1

1

hmdne on the Opal Slack has pointed me to opal-browser which includes the Browser::FormData.parse_query(s) method.

Benjamin Oakes
  • 12,262
  • 12
  • 65
  • 83