0

I am having an application using Angular, which communicates with backend via rests. I am facing a problem with encoding of my questionares.

Angular part:

  searchCase(searchText: string): Observable<Case[]> {
    const encodedText = encodeURIComponent(searchText);
    return this.http.get<Case[]>(`${this.baseUrl}/case/search/${encodedText}`);
  }

Rest:

public List<Case> searchCase(
        @PathParam("searchedText") String searchedText) {
    return caseManagement.searchCase(searchedText);
}

For any input, this works totally fine, except for backslash. Then, it does not even reach my backend rest part. How can I go over it?

Maciej Miśkiewicz
  • 412
  • 2
  • 8
  • 22

1 Answers1

0

It turned out that it was enough to use btoa instead:

searchCase(searchText: string): Observable<Case[]> {
    const encodedText = btoa(searchText);
    return this.http.get<Case[]>(`${this.baseUrl}/case/search/${encodedText}`);
  }

And then decode it on backend side and seems to work totally fine.

Maciej Miśkiewicz
  • 412
  • 2
  • 8
  • 22