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

Viewed 665

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 COURSE_ROUTES: Routes = [
  {path: '', redirectTo: '/', pathMatch: 'full'},
  {path: ':name', component: CourseComponent},
  {path: '**', component: ErrorComponent}
];

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

course/<script>alert('0wn3d')</script>,

its throwing an error as

ERROR Error: Uncaught (in promise): Error: Cannot match any routes. URL Segment: ''0wn3d'' Error: Cannot match any routes. URL Segment: ''0wn3d'

though I have written a wild card entry for error routes. I have tested that the

{path: '**', component: ErrorComponent}

is showing the 404 error page, by removing the

{path: ':name', component: CourseComponent}

and running the app with some random url like course/some-course

Please help me resolve this. Thanks in advance.

1 Answers
Related