I'm really struggling to find a solution for this issue. I'm currently working on designing a search engine that displays the user's query in the URL like this:
https://my-site.com/search;query=%28rockstar;search=true;page=0
The user is looking for the phrase (rockstar
.
When I enter this URL into the browser, it functions as expected. However, Google Chrome displays the URL differently:
https://my-site.com/search;query=(rockstar;search=true;page=0
So, the %28
gets changed to (
. I'm not sure if this behavior is specific to Angular or dependent on the browser. When the URL contains (
, hitting F5
for refresh does not work because the Angular Router reports an error like this:
Cannot match any routes. URL Segment: 'rockstar;search=true;page=0'
Copying the link from the address bar is also ineffective due to this conversion issue - the copied link includes the character (
instead of %28
. How can I prevent special characters like %28
from being decoded by the browser in the URL address bar? This problem has emerged in Angular v5.2.5.
Here is a demo showcasing this problem:
It should be noted that in Angular 6, this issue no longer exists: