hanami / router

Ruby/Rack HTTP router
http://hanamirb.org
MIT License
362 stars 92 forks source link

Failing edge cases for optional variables #247

Open jandudulski opened 1 year ago

jandudulski commented 1 year ago

I would like to use such pattern: /(something/:optional/)and/:always but router doesn't catch it. Failing test:

    describe "optional variable with variable" do
      let(:router) do
        described_class.new do
          get "/(test1/:foo/)test2/:bar", as: :variable, to: RecognitionTestCase.endpoint("variable")
        end
      end

      it "recognizes route(s)" do
        runner.run!([
          [:variable, "/test1/foo/test2/bar", {foo: "foo", bar: "bar"}],
          [:variable, "/test2/bar", {foo: nil, bar: "bar"}]
        ])
      end
    end
 Failure/Error: expect(name).to be_nil

  expected: nil
       got: :variable

I'm not sure if it's bug or my bad usage?