title: Angular 7 change parentheses for %28 and %29 in url
body: <p>I have a problem with angular routes. In my app, I have a login session expiration time. So when the user is not active for 15 minutes - the app will ask him to login again. </p>
  
  <p>At this time I am saving current active url in the store and want to redirect the user to it after login. I am doing this in effects with <code>this.router.navigate([backUrl])</code>.</p>
  
  <p>The problem is that some routes with parentheses, for example this <code>http://localhost:4200/somedata/details/3043/edit/(modal:activity/6b9f7a3e-93c9-418f-a172-c2fa648d1be7)</code> is converted to <code>http://localhost:4200/somedata/details/3043/edit/%28modal:activity/6b9f7a3e-93c9-418f-a172-c2fa648d1be7%29</code>and in this page is not recognized by routes.</p>
  
  <p>I tried to use <code>CustomUrlSerializer</code> to fix this problem:</p>
  
  <pre><code>export class CustomUrlSerializer implements UrlSerializer {
    private defaultUrlSerializer: DefaultUrlSerializer = new DefaultUrlSerializer();
  
    parse(url: string): UrlTree {
      // Encode parentheses
      url = url.replace(/\(/g, '%28').replace(/\)/g, '%29');
      // Use the default serializer.
      return this.defaultUrlSerializer.parse(url);
    }
  
    serialize(tree: UrlTree): string {
      return this.defaultUrlSerializer.serialize(tree).replace(/%28/g, '(').replace(/%29/g, ')');
    }
  }
  </code></pre>
  
  <p>And added to App.module providers <code>{ provide: RouterStateSerializer, useClass: CustomRouterStateSerializer },</code>
  But then i am always redirected to NotFound page for urls with parentheses if i am trying to open them in new browser window or just refresh page. But it still work for relative routes. Like from this url <code>http://localhost:4200/somedata/details/3043/edit</code> i can open my component by path <code>(modal:activity/6b9f7a3e-93c9-418f-a172-c2fa648d1be7)</code></p>