Pode.Web icon indicating copy to clipboard operation
Pode.Web copied to clipboard

URL encode DataValue when moving page

Open Badgerati opened this issue 2 years ago • 1 comments

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.

Badgerati avatar Sep 04 '23 20:09 Badgerati

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:

  1. We don't support overloading -DataValue with extra query params by += "?NewParamName=$foo" anymore and proceed with a basic URLEncode.
  2. We either replace -DataValue with or add -QueryParamaters where people send a hashtable with their data values. Migration guide if we go replace says "replace -DataValue $foo with -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.

Szeraax avatar Feb 21 '24 07:02 Szeraax