tomnomnom / qsreplace

Accept URLs on stdin, replace all query string values with a user-supplied value
MIT License
755 stars 123 forks source link

qsreplace does not replace each parameter only once #9

Open mikedesu opened 2 years ago

mikedesu commented 2 years ago

Perhaps I am misunderstanding how qsreplace is intended to work, but considering the description of the tool, I am receiving unexpected output. qsreplace is replacing every parameter value, not individually.

~ % cat urls.txt 
https://www.evildojo.com/index.php?q=search&name=darkmage
https://www.evildojo.com/index.php?q=search
https://www.evildojo.com/index.php
https://www.evildojo.com

~ % cat urls.txt | qsreplace d3v
https://www.evildojo.com/index.php?name=d3v&q=d3v
https://www.evildojo.com/index.php?q=d3v
https://www.evildojo.com/index.php
https://www.evildojo.com

The output I am expecting, however, is below:

https://www.evildojo.com/index.php?q=d3v
https://www.evildojo.com/index.php?q=d3v&name=darkmage
https://www.evildojo.com/index.php?q=search&name=d3v

I am releasing a tool to achieve this functionality, but I think it would be nice if this tool did it instead.

bugoverfl0w commented 1 year ago

share your tool bro. Did you mean

?a=b&c=d should be results: ?a=b'&c=d ?a=b&c=d'?

mikedesu commented 1 year ago

Sorry I'm just now seeing this!

The tool was released in pypi as queryswap:

https://pypi.org/project/queryswap/

https://github.com/mikedesu/qs

To install:

pip3 install queryswap

To use:

echo "https://www.evildojo.com/index.php?q=a&v=b" | python3 -m qs d3v