URL encode DataValue when moving page
Describe the Bug
Move-PodeWebPage doesn't URL encode the -DataValue parameter, which means certain characters behave unexpectedly - like + turning into a space.
One thing to note here is being able to handle multiple query parameter values. Some people supply multiple values to -DataValue and URL encoding this will malform ? and & characters.
I don't see where ? would ever be used. I searched the discord and don't see anyone doing it. I do see an example of using &, but that's as an ugly hack to append extra query params to the page. You once suggested:
It it hardcoded to Value=, buuuut I don't see any reason we couldn't have some -Properties hashtable parameter on that function which adds to the query string 🤔
I would suggest that:
- We don't support overloading
-DataValuewith extra query params by+= "?NewParamName=$foo"anymore and proceed with a basic URLEncode. - We either replace
-DataValuewith or add-QueryParamaterswhere people send a hashtable with their data values. Migration guide if we go replace says "replace-DataValue $foowith-QueryParameters @{Value=$foo}" and move on.
Thoughts?
Let me know what you'd like and I'll submit a PR to review.
If you don't want to break the ugly hack with DataValue -> query string parameters, we can just replace all & with something like =amp= or |amp| or something, do the URL encode, and then replace that string back with &. Again, this is a dirty hack and I don't think you should be supporting it. I think you should go with the -QueryParameters hashtable approach, but let me know what you'd like and I'll do it.