Skip to content

Commit

Permalink
fixing scanner for path tokenization. fixes rails#1
Browse files Browse the repository at this point in the history
  • Loading branch information
tenderlove committed Oct 31, 2011
1 parent 3bd8d05 commit e05701c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
2 changes: 0 additions & 2 deletions lib/journey/nfa/transition_table.rb
Expand Up @@ -72,8 +72,6 @@ def generalized_table
end
end

final_state = state_id.length + 1

final_groups = state_id.keys.find_all { |s|
s.sort.last == accepting
}
Expand Down
2 changes: 1 addition & 1 deletion lib/journey/scanner.rb
Expand Up @@ -47,7 +47,7 @@ def scan
[:DOT, text]
when text = @ss.scan(/:\w+/)
[:SYMBOL, text]
when text = @ss.scan(/\w+/)
when text = @ss.scan(/[\w-]+/)
[:LITERAL, text]
# any char
when text = @ss.scan(/./)
Expand Down
17 changes: 17 additions & 0 deletions test/test_router.rb
Expand Up @@ -28,6 +28,23 @@ def hello
end
end

def test_dashes
klass = FakeRequestFeeler.new nil
router = Router.new(routes, {})

exp = Router::Strexp.new '/foo-bar-baz', {}, ['/.?']
path = Path::Pattern.new exp

routes.add_route nil, path, {}, {:id => nil}, {}

env = rails_env 'PATH_INFO' => '/foo-bar-baz'
called = false
router.recognize(env) do |r, _, params|
called = true
end
assert called
end

def test_request_class_and_requirements_success
klass = FakeRequestFeeler.new nil
router = Router.new(routes, {:request_class => klass })
Expand Down

0 comments on commit e05701c

Please sign in to comment.