I want to get an URL as a get aparameter
ex: example.com?domain=site.come?a=val&b=val
the problem when i use
query := r.URL.Query()
domain := query.Get("domain")
to get the domain name it give just domain=site.come?a=val
I think because when the r.URL.Query() meet & it consider it as a new parameter
does anyone know how can I solve this problem
Thank you in advance.
You need to URL-Encode your query string, like this:
Which outputs
domain=example.com%3Ffoo%3Dbar
.You can set that string as a
RawQuery
of anurl.URL
value and if you then access the query like you did, it will have the correct value.If the URL is correctly encoded then you should be able to run the following code with your URL value and get the correct result:
This prints:
(the complete URI with the encoded parameter called "domain")
(the decoded value of said parameter)