Library for URL parameters adding, removing, or replacing?

i think PHP doesn’t have such simple functions yet… does Ruby have
it?

if in PHP, when we add a param to the URL

$redirectURL = $printPageURL . “?mode=1”;

it works if $printPageURL is “http://www.somesite.com/print.php”, but if
$printPageURL is changed in the global file to
http://www.somesite.com/print.php?newUser=1”, then the URL becomes
badly formed. If the project has 300 files and there are 30 files that
append param this way, we need to change all 30 files.

the same if we append using “&mode=1” and $printPageURL changes from
http://www.somesite.com/print.php?new=1” to
http://www.somesite.com/print.php”, then the URL is also badly formed.

is there a library in Ruby/Rails that will automatically handle the “?”
and “&”, and even checks that existing param exists already and removed
that one because it will be replaced by the later one and it is not good
if the URL keeps on growing longer?

URL paramaters are usually passed as a hash, with that if a new key
matches and existing key the new key/value pair will overwrite the
existing key/value pair thus preventing duplicate entries.

Ben

On May 26, 11:47 am, Jian L. [email protected]