Skip to content

Sinatra::Namespace breaks route with named parameters ? #1409

@scalp42

Description

@scalp42

Hi folks,

Running into an issue upgrading to Sinatra 2.

This route works fine without Sinatra::Namespace:

class TestController < MainController
  get '/i/love/:framework.?:format?' do
    params.to_json
  end
end
$> http --body localhost:9393/v1/i/love/sinatra

{
    "captures": [],
    "format": null,
    "framework": "sinatra"
}

$> http --body localhost:9393/v1/i/love/sinatra.json

{
    "captures": [],
    "format": "json",
    "framework": "sinatra"
}

If I try to namespace the same route with Sinatra::Namespace:

class TestController < MainController
  register Sinatra::Namespace

  namespace '/hey' do
    get '/i/love/:framework.?:format?' do
      params.to_json
    end
  end
end

It won't start:

$> bundle exec puma --port=9393 config.ru

Puma starting in single mode...
* Version 3.11.3 (ruby 2.5.0-p0), codename: Love Song
* Min threads: 2, max threads: 10
* Environment: development

! Unable to load application: Mustermann::Error: #<Class:0x00007fb6e10c22a0>: Cannot translate Mustermann::AST::Node::WithLookAhead

Here is the full trace: https://gist.github.com/scalp42/e627e470c6169e3f4be380cea327b697

Any ideas? 🤔

Thanks in advance for the help!

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions