Angular 4 throwing Cannot match any route error with XSS script in url

I am developing an application in Angular 4. When I try to write routes for a functional module, I get an error like Error: Cannot match any routes.

Here's the route code I used:

const COURSE_ROUTES: Routes = [
  {path: '', redirectTo: '/', pathMatch: 'full'},
  {path: ':name', component: CourseComponent},
  {path: '**', component: ErrorComponent}
];

      

The routing works fine and goes to CourseComponent

when the route is similar to course/angular

or course/some-course-name

, but when I try to inject some XSS script into the same route, for example

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

,

its error:

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

although I wrote a wild card entry for error routes. I tested that

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

      

shows a 404 error page by deleting

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

      

and launching the application with some random url like course/some-course

Please help me to solve this problem. Thanks in advance.

+3


source to share


1 answer


Cannot be given /

as root url.

  {path: 'some-name:name',pathMatch: 'full',component:CourseComponent}

      



Documented here

enter image description here

+1


source







All Articles