I have a problem with plus (+) in Angular 9 that is replaced with space. The use case is as following:
I'm clicking on a link:
https://myapp.com/invitation?code=h7d8wdh7ddjwkdfhg93&email=alan.jack+432@gmail.com
On the frontend we are intercepting the request:
@Component({
selector: '-my-app',
templateUrl: ...
styleUrls: ...,
changeDetection: ChangeDetectionStrategy.OnPush
})
export class MyAppComponent {
constructor(private activatedRoute: ActivatedRoute,
private router: Router) {
this.watchForInvitation();
}
private watchForInvitation() {
this.activatedRoute.queryParams.pipe(
filter(params => params.code && params.email),
switchMap(params => {
const code = params.code;
const email = params.email;
const body: UserInfo = {
emailAddress: email, //email without + -> how to prevent the plus sign from being removed?
};
return this.usersHttpService.accept(code, body); //body should be with plus and not with space
}),
).subscribe(_ => {
...
}, err => {
...
});
}
}
Below the accept method from service:
usersHttpService:
accept(code: string, user: UserInfo) {
return this.http.post(`${this.env.MY URL}/mon/accepting/${code}/accept`, user);
}
How to prevent the plus sign from being removed in my example? Frontend receives the correct URL with + but then the plus sign is somehow removed.