Angular event instanceof NavigationEnd

I had a line of code that looked like let last = event.url.split("/").pop();

I usually use event.url whenever I subscribe to this.router.events.subscribe((event)

but I realized that I should be using event.urlAfterRedirects

Here is the full story.

When I was testing my code it worked whenver I went directly to the URL in question. event.url would get the 'model-home' that I was expecting. However it would not work if I navigated to the page in question. The route I would navigate to is /vehicle/:id , and this is due to redirects...

My Route file looks like this { path: "", redirectTo: "model-home", pathMatch: "full" }, { path: "model-home", component: VehicleHomeComponent, },

By having a redirect in my Router the event now has the urlAfterRedirects property url: "/list/098f1ebd9f35/vehicle/22839" urlAfterRedirects: "/list/098f1ebd9f35/vehicle/22839/model-home"