Right, so straight to it.
You want to pass an email with a special character/s as part of a query in a url using javascript.
Simples.
All we have to do is utilise the function encodeURIComponent
.
const email = 'test+1@test.com';
const encoded = encodeURIComponent(email);
const url = `https://url.com/?email=${encoded}`;
console.log(url); // "https://url.com/?email=test%2B1%40test.com"
and voila...problem solved.
Top comments (0)