grafana/jslib.k6.io

URLSearchParams not picking some values

sealr00t opened this issue · 0 comments

I'm trying to extract values from a url that is encoded. but there seems to be a problem with the URLSearchParams class. The first search param in the url right after the '?' symbol is never being picked and always returns a null when quired.

Here's a code snippet to prove it.
let encoded = 'endpoint1/endpoint2/result%3Ftoken=xyz...&id=19bc...&refresh=Swib3...&source=unknown&token_type=Bearer'; try { console.log(decodeURIComponent(encoded)); } catch (e) { console.error(e); } let params = new URLSearchParams(decodeURIComponent(encoded)); let token = params.get("token"); let id = params.get("id"); console.log(token); console.log(id); console.log(params.get("refresh")); console.log(params.get("source")); console.log(params.get("token_type"));