rails / journey

A router for rails
221 stars 57 forks source link

Route#format is inconsistent for optional substrings #50

Open dougo opened 12 years ago

dougo commented 12 years ago

Route#format gets a little confused when an optional substring doesn't include a symbol argument:

#!/usr/bin/env ruby

require 'journey'

def format(path, opts = {})
  pattern = Journey::Path::Pattern.new(path)
  route = Journey::Route.new(nil, nil, pattern, {})
  route.format(opts)
end

puts format('/foo(bar)')
puts format('/foo(bar)/:baz', :baz => 42)

# output:
#
# bash-3.2$ ./journey_bug.rb
# /foo
# /foobar/42
#
# Why are these not either both foo or both foobar?