Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

config.include regExes should match the camelCased route names now #276

Closed
OtherCroissant opened this issue Jun 2, 2021 · 2 comments
Closed

Comments

@OtherCroissant
Copy link

In the new version, the config.include (and probably config.exclude) seem to match the camelCased base_names of the routes. Previously, these filters worked based on the underscored Route names, as used in Rails. Nowadays (I am not currently sure which version changed this), I have to rewrite this filter to camelCased regexes.

For example:

  config.include = [
    /^admin$/,
    /^admin_front_page$/,
    /^not_your_average_admin_front_page$/

should be rewritten to:

  config.include = [
    /^admin$/,
    /^adminFrontPage$/,
    /^notYourAverageAdminFrontPage$/

I don't really mind this change, but for other users, it could be a breaking change.

Also I guess that this example of the readme does not work any longer because it tries to match on the underscore:

JsRoutes.generate!("#{path}/app_routes.js", exclude: [/^admin_/, /^api_/])
JsRoutes.generate!("#{path}/adm_routes.js", include: /^admin_/)
JsRoutes.generate!("#{path}/api_routes.js", include: /^api_/, default_url_options: {format: "json"})

Maybe you could also include an example with a larger path?

@bogdan bogdan closed this as completed in 5ac1980 Jun 2, 2021
@OtherCroissant
Copy link
Author

So, I guess it was a bug? thanks for the rapid fix!

@bogdan
Copy link
Collaborator

bogdan commented Jun 2, 2021

Yes, I had no intent to change that and I don't see any reason why new way is better than the old. Overall I don't like how include/exclude options are working. They should really apply to route spec like /admin/posts/:post_id instead of helper name, but that is a story for another time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants