Got Error: Cannot match any routes. URL Segment:

1.7k views Asked by At

Angular App throwing Cannot match any routes error with XSS script in URL :

I am developing an application in Angular 4. When I am trying to write routes for a feature module, I am getting an error as Error: Cannot match any routes.

Here's the routes code I have used:

const ROUTES: Routes = [
  {path: '', redirectTo: '/', pathMatch: 'full'},
  {path: 'test/:name', component: TestCompnent},
  {path: '**', component: TestCompnent}
];

Routing is working fine and going to the TestCompnent when the route is something like test/angular or test/some-course-name but when I try to inject some XSS script into the same route, such as

test/<script>alert('hello')</script>,

its throwing an error as

Error: Cannot match any routes. URL Segment: ''hello'' Error: Cannot match any routes. URL Segment: ''hello''

1

There are 1 answers

2
Chund On

That is expected and wanted behavior, since XSS is a major vulnarability for most services. Therefor the guys and girls over at Google did their best to disable them. Docs