railsware / js-routes

Brings Rails named routes to javascript
http://railsware.github.io/js-routes/
MIT License
1.61k stars 151 forks source link

Different behavior with optional parameters #274

Closed pustovalov closed 3 years ago

pustovalov commented 3 years ago

routes.rb

resources :campaigns, except: [:index, :update, :destroy], path: '(/:space)/campaigns', space: ALLOWED_PRODUCT_SPACES_REGEXP, defaults: {space: nil} do

1.4.14

Routes.site_campaign_path('test', 'loyalty', 1)
"/sites/test/loyalty/campaigns/1"

Routes.site_campaign_path('test', '', 1)
"/sites/test/campaigns/1"

Routes.site_campaign_path('test', false, 1)
"/sites/test/campaigns/1" //diff

2.0.0 and 2.0.1

Routes.site_campaign_path('test', 'loyalty', 1)
"/sites/test/loyalty/campaigns/1"

Routes.site_campaign_path('test', '', 1)
"/sites/test/campaigns/1"

Routes.site_campaign_path('test', false, 1)
"/sites/test/false/campaigns/1" //diff

Is this the expected behavior?

bogdan commented 3 years ago

I've fixed that. The problem is tricky though because rails itself has problems with it: rails/rails#42280