rubyonjets/jets

Routing is broken for mounted rack apps

wivarn opened this issue · 0 comments

  • Upgrade Jets: Are you using the latest version of Jets? This allows Jets to fix issues fast. There's a jets upgrade command that makes this a simple task. There's also an Upgrading Guide: http://rubyonjets.com/docs/upgrading/
  • Reproducibility: Are you reporting a bug others will be able to reproduce and not asking a question. If you're unsure or want to ask a question, do so on https://community.rubyonjets.com
  • Code sample: Have you put together a code sample to reproduce the issue and make it available? Code samples help speed up fixes dramatically. If it's an easily reproducible issue, then code samples are not needed. If you're unsure, please include a code sample.

My Environment

Local env only

Software Version
Operating System any
Jets 3+
Ruby any

Expected Behaviour

All nested paths under a mounted rack app should route to the rack app and work provided the action is actually defined. If the action is not defined the rack app should return some kind of error.

Current Behavior

The root path of a mounted rack app works but any nested paths will fail including adding a slash after the root path.
Example: DOMAIN/sinatra will route to the root for a mounted sinatra app. DOMAIN/sinatra/ or DOMAIN/sinatra/* will fail.

Step-by-step reproduction instructions

  1. Checkout https://github.com/boltops-tools/jets-routes-mount
  2. Update jets to any version 3+
  3. go to sinatra/hello

Code Sample

This bug was introduced in 3.0.0:
https://github.com/boltops-tools/jets/blob/19228b9bd528a6cbfb10fd68da64426bb3ac2e5f/lib/jets/controller/rack/env.rb#L16
Before 3.0.0, path would be assigned directly

path = @event['path'] ... # sinatra/hello

After 3.0.0 path_with_base_path is used. It returns /sinatra/{path+} which breaks further up the stack since it's not a valid URI.

I poked around with byebug using the example linked above. The event hash currently have the following values:

resource = @event['resource'] # "/sinatra/{path+}"
pathParameters = @event['pathParameters'] # {"path"=>"hello"}