appendQueryParam

open fun appendQueryParam(url: String, param: String): String

Append a query parameter to a url, picking the right separator.

Call sites used to hard-code "?", which produced a second "?" whenever the url already carried a query string. The server then folded the parameter into the preceding value (...?property=2231?data=uat) and never saw it at all.

Return

the url with the parameter appended, or the url unchanged when there is nothing to append

Parameters

url

url to append to, with or without an existing query string

param

parameter in name=value form, without a separator