This is a migrated thread and some comments may be shown as answers.

Fixing URLs for requested routes

1 Answer 82 Views
SPA
This is a migrated thread and some comments may be shown as answers.
Dustin
Top achievements
Rank 1
Dustin asked on 23 Jul 2013, 01:55 PM
If I register a route for this for example..."/view(/:category)(/:name)" this works just fine..."http://localhost:6699/test/view/home/index". But, if you request "http://localhost:6699/test/view/home/index/" with a trailing slash the route missing is triggered. I tried using regex in the route change event to remove trailing a slash if it exists, but that has no effect b/c after looking at your source code the url you modify in the change event doesn't update back to the url in the caller. So, how can I fix these type of route request or is this a bug with your SPA framework?

Currently I have to register two routes where one ends w/ a slash and both provide the same callback. But, this is not efficient to have to register two routes for each route needed. So, if I have 25 possible routes, then I have to register 50.

Or is there a way I can specify and optional trailing slash end the route definition?

1 Answer, 1 is accepted

Sort by
0
Petyo
Telerik team
answered on 25 Jul 2013, 08:50 AM
Hello Dustin,

You can use optional segments for that purpose. I prepared a small sample to demonstrate the needed approach.

Regards,
Petyo
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
SPA
Asked by
Dustin
Top achievements
Rank 1
Answers by
Petyo
Telerik team
Share this question
or