* Encodes a stringified TestQuery so that it can be placed in a `?q=` parameter in a URL.
*
* `encodeURIComponent` encodes in accordance with `application/x-www-form-urlencoded`,
* but URLs don't actually have to be as strict as HTML form encoding
* (we interpret this purely from JavaScript).
* So we encode the component, then selectively convert some %-encoded escape codes
* back to their original form for readability/copyability.
*/
export function encodeURIComponentSelectively(s: string): string {
let ret = encodeURIComponent(s);
ret = ret.replace(/%22/g, '"');
ret = ret.replace(/%2C/g, ',');
ret = ret.replace(/%3A/g, ':');
ret = ret.replace(/%3B/g, ';');
ret = ret.replace(/%3D/g, '=');
ret = ret.replace(/%5B/g, '[');
ret = ret.replace(/%5D/g, ']');
ret = ret.replace(/%7B/g, '{');
ret = ret.replace(/%7D/g, '}');
ret = ret.replace(/%E2%9C%97/g, '✗');
return ret;
}