gojek/wrest

Inconsistent behaviour while creating a template from a URI

Opened this issue · 0 comments

Executing following code

base = 'http://foo.com/api/xml'.to_uri
p base.to_template("bar/:id").uri_pattern

base = 'http://foo.com/api/xml/'.to_uri
p base.to_template("bar/:id").uri_pattern

base = 'http://foo.com/api/xml'.to_uri
p base.to_template("/bar/:id").uri_pattern

Produces

"http://foo.com/api/bar/:id"

"http://foo.com/api/xml/bar/:id" # Expected behaviour (Considering p base["/bar"].uri_string to be standard)

"http://foo.com/bar/:id"

Note that 'xml' is dropped in first case where as only base path is considered in last.