tricknotes / ember-cli-rails

Unify your EmberCLI and Rails Workflows
http://thoughtbot.github.io/ember-cli-rails/
MIT License
713 stars 205 forks source link

Automatically redirect with a trailing slash when needed #560

Closed drcapulet closed 6 years ago

drcapulet commented 6 years ago

For apps not mounted at /, apps need to write custom redirect login to add the trailing slash Ember requires - this simplified it by providing it as part of mount_ember_app.

seanpdoyle commented 6 years ago

Thanks for opening this PR.

Could you rebase off of the latest master and try running this change through CI?

drcapulet commented 6 years ago

@seanpdoyle looks like that fixed it, thanks!

seanpdoyle commented 6 years ago

This change would redirect all Ember routes to corresponding paths ending in /.

Could you please elaborate a bit more on your use case?

Could this the application-global effects break Ember routes that are meant to end without a /?

Would /posts map to a posts route, and posts/ require a posts.index route?

Does Ember routing treat /posts equivalent to posts/?

drcapulet commented 6 years ago

@seanpdoyle this PR only redirects the root URL. If you've got an app mounted at /admin, any requests to /admin will be redirected to /admin/ because Ember requires a trailing slash when visiting the root URL - see emberjs/ember.js#4751. Otherwise, the request isn't touched by these changes.

nruth commented 6 years ago

I like this. We currently work around this by adding rack-rewrite rules for each mounted app.

seanpdoyle commented 6 years ago

Merged in https://github.com/thoughtbot/ember-cli-rails/commit/d5b19df706695d3a0a822f6f0fb5ef37e152840a.

Thanks!

imack commented 2 years ago

@seanpdoyle if we're redirecting to a url with query parameters, this seems to have a / at the end of it, putting all the query params into the route. ie. /url?query=test/