Re: Discharging action QT4CG-042-03

Norm Tovey-Walsh <norm@saxonica.com> writes:

> ...
> Given
>
>   …?a=1&b=2&a=3
>
> We’re going to get
>
>   "query-parameters": map {
>     "a": ("1", "3"),
>     "b": "2"
>   }
>
> The description of how to reconstruct the query part of the URI in
> build-uri will naturally yield:
>
>   …?a=1&a=3&b=2
>
> ...
> If a user really needs to be able to reconstruct “a=1&b=2&a=3”, I think
> the’ll have to do it themselves (which is always possible).

I think you are thinking about the round trip through parsing the URI
and building a URI.  Fair enough: I can see how a user can construct the
string "a=1&b-2&a=3" at need (assuming they fight their way through the
thickets of URI escaping or limit themselves to simple and blameless
query parameters which need no escaping).

But just to be sure I understand -- if the user of parse-uri() needs the
original order (because the query string is defined by the application
not as a set or bag of parameters but as a sequence of parameters), they
can do it themselves because the have access to the original URI query
string, right?

  let $map := parse-uri("http://example.org/?a=1&b=2&a=3")
  return $map('query')

and then they just parse it themselves into a sequence or array of
name/value pairs. Right?  I can live with that -- I don't think URIs are
*that* hard to parse, and our motive is not that they are too hard to
parse but that the task is common enough to provide a convenience
function.

Assuming I have understood all this correctly, I'm happy with your
recommendation.

Michael

-- 
C. M. Sperberg-McQueen
Black Mesa Technologies LLC
http://blackmesatech.com

Received on Thursday, 14 September 2023 00:30:05 UTC