I am trying to get email from URL without decoding.
URL: https://localhost:3000/register/activate?token=JAItBAPArUSukXae0Q3J&email=kiran+39@gmail.com
Note: Due to some technical limitation I can not encode the URL. Since it's coming from a third party vendor.
Initial code:
var email = qs.parse(window.location.search, {
ignoreQueryPrefix: true,
}).email;
This works but when email has "+" sign it decodes it as " ". So, I am trying to replace spaces with "+" again with the below code. But I am having some issue with types. Can you please help me what's the best way to fix this.
Code:
let email: string =
qs.parse(window.location.search, {
ignoreQueryPrefix: true,
}).email || "";
if (email) email.replace(/ /g, "+");
But I am getting a type error:
Argument of type 'string | string[] | ParsedQs | ParsedQs[] | undefined' is not assignable to parameter of type 'string'
