Ruby, How to add a param to an URL that you don't know if it has any other param already
I have to add a new param to an indeterminate URL, let's say param=value . In case the actual URL has already params like this http://url.com?p1=v1&p2=v2 I should transform the URL to this other: http://url.com?p1=v1&p2=v2¶m=value But if the URL has not any param yet like this: http://url.com I should transform the URL to this other: http://url.com?param=value I feel worry to solve this with Regex because I'm not sure that looking for the presence of & could be enough. I'm thinking that maybe I should transform the URL to an URI object, and then add the param and transform it to String