Is there a groovy/grails equivalent to PHP's parse_url ( http://php.net/manual/en/function.parse-url.php ) or python's urlparse ( http://docs.python.org/library/urlparse.html ) that turns a URL string into a struct containing host,protocol, querystring, fragment, URI, etc?
I thought it might be in the grails.org/doc/latest/api/org/codehaus/groovy/grails/web/util/WebUtils.html , but didnt see anything. I dont think HTTPBuilder or assorted URLMapping utilities are what I need.
I really just want to pull a map out of the path and queryString and handle the edge cases (array of params /blah/fuzz?foo=bar&foo=baz
, fragments /blah/fuzz?foo=bar#baz
, encoded URLs for redirects) correctly.
I know I can handle the PATH component via clever use of URLMapping eg: /blah/$code
, but im left with decoding the param block...
Thanks
If I understand correctly, what you really need is plain old URI class:
new URI('http://google.com/?q=URL').query
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With