0

I'm having a problem similar to this one, and i can't solve it. I have the following path:

/task/ui/pep_uid_1/VmFsdXRhemlvbmVDb2xsZWdhdGFQRVA6NTA2Mw==/edit

But, as soon as i try to navigate to this page, i get this error:

ERROR Error: Uncaught (in promise): Error: Cannot match any routes. URL Segment: 'task/ui/pep_uid_1/VmFsdXRhemlvbmVDb2xsZWdhdGFQRVA6NTA2Mw%3D%3D/edit'

As you can see, the symbol '=' at the end of the path is being replaced by '%3D'

I tried to implement a CustomUrlSerializer as follows:

import {UrlSerializer, UrlTree, DefaultUrlSerializer} from '@angular/router';

export class CustomUrlSerializer implements UrlSerializer {
    parse(url: any): UrlTree {
        debugger;
        console.log('CustomUrlSerializer parse');
        let dus = new DefaultUrlSerializer();
        return dus.parse(url);             
    }

    serialize(tree: UrlTree): any {
        debugger;
        console.log('CustomUrlSerializer serialize');
        let dus = new DefaultUrlSerializer(),
        path = dus.serialize(tree);
        console.log('path before: '+ path);
        // use your regex to replace as per your requirement.          
        path = path.replace(/%3D/g,'=');        
        console.log('path after: '+ path);
        return path;
    }
}

If i run my application, the console output shows that the custom serializer is working just fine:

path before: /task/ui/pep_uid_1/VmFsdXRhemlvbmVDb2xsZWdhdGFQRVA6NTA2Mw%3D%3D/edit
path after:  /task/ui/pep_uid_1/VmFsdXRhemlvbmVDb2xsZWdhdGFQRVA6NTA2Mw==/edit

But then i keep getting the same routing error, and the console shows that the router is still searching for the wrong path

ERROR Error: Uncaught (in promise): Error: Cannot match any routes. URL Segment: 'task/ui/pep_uid_1/VmFsdXRhemlvbmVDb2xsZWdhdGFQRVA6NTA2Mw%3D%3D/edit'

What am i missing? Thanks in advance

rekotc
  • 533
  • 1
  • 10
  • 20

0 Answers0