justinfagnani / route

A client + server routing library for Dart
BSD 3-Clause "New" or "Revised" License
114 stars 40 forks source link

router matcher does not handle correctly paths with common prefix #50

Closed tomaszkubacki closed 10 years ago

tomaszkubacki commented 10 years ago

eg.

router.root.addRoute(name: "book", path: "/book", enter: book ); router.root.addRoute(name: "bookings", path: "/bookings", enter: bookingList );

then go to /bookings causes: log: More than one route matches /bookings [[Route: book], [Route: bookings]]

pavelgj commented 10 years ago

You should always have the more specific route first, which would solve your problem.

router.root
  ..addRoute(name: "bookings", path: "/bookings", enter: bookingList)
  ..addRoute(name: "book", path: "/book", enter: book);
tomaszkubacki commented 10 years ago

@pavelgj - this will work - however it still matches 'book' route for 'bookings' (and logs error)

pavelgj commented 10 years ago

I wouldn't worry about the warning. I will probably demote it to a "fine" log message instead. This is the correct behavior -- router picks the first matching route.