Why is the @ sign being turned into %40 in dynamic page urls?

Hi,
I am trying to use a members email as the final part of the url in a dynamic page eg: www.mywebsite.com/members/{email} . But the @ sign in the email address is being turned into %40.
So when I try to use wixLocation.to current members email that directs to tims@email.com but the URL for the dynamic page is tims%40email.com .
Here is the code for the redirect:


let userEmail;
   wixUsers.promptLogin( {"mode": "login"} )
      .then( (user) => {
 
 return user.getEmail();
      } )
      .then( (email) => {
 // check if there is an item for the user in the collection
        userEmail = email;
      })
 
export function profilebutton_click(event) {
  wixLocation.to(`/members/${userEmail}`); 
}

I have read that you need a URL decoder when using the @ sign but I am not sure if that is possible with wix.
Maybe i could change all @ signs in userEmail with %40 but I am not sure how I would do that.

All help is appreciated.
Thank you so much!

Ps: I know that it is prompting a login but i dont think that matters here. Let me know if I am wrong.

Hi.

You can use replace Javascript method to replace @ with %40. See code below:

let userEmail;
wixUsers.promptLogin({ "mode": "login" })
    .then((user) => {

 return user.getEmail();
    })
    .then((email) => {
 // check if there is an item for the user in the collection
        email.toString()//convert email to string
        userEmail = email.replace('@', '%40');//replace @ with %40
    })

Good luck!