1602/railway-routes

Order in `only` param matters

Closed this issue · 2 comments

If I call resources with {only: ['index', 'show', 'new', 'create']}, /resource/new is interpreted as a show request for id new.

This only happens when you use only?

Looking at the code this seems to be the case, yes. The other options depend on the order the keys of availableRoutes are iterated. This order is not guaranteed to be what you might expect, but it works in most if not all JS environments I know. Since order matters so much I would suggest to use an array, though.