http_router 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.2
1
+ 0.2.3
@@ -138,8 +138,15 @@ class HttpRouter
138
138
  end
139
139
 
140
140
  def find_on_parts(request, parts, params)
141
- unless parts.empty?
141
+ if parts and !parts.empty?
142
142
  whole_path = parts.join('/')
143
+ if parts.size == 1 and parts.first == ''
144
+ potential_match = find_on_parts(request, [], params)
145
+ if potential_match and (router.ignore_trailing_slash? or potential_match.value && potential_match.value.route.trailing_slash_ignore?)
146
+ parts.shift
147
+ return potential_match
148
+ end
149
+ end
143
150
  if @linear && !@linear.empty?
144
151
  response = nil
145
152
  dupped_parts = nil
@@ -163,9 +170,6 @@ class HttpRouter
163
170
  elsif @catchall
164
171
  params << @catchall.variable.consume(parts, whole_path)
165
172
  return @catchall.find_on_parts(request, parts, params)
166
- elsif parts.size == 1 && parts.first == '' && (value && value.route.trailing_slash_ignore? || router.ignore_trailing_slash?)
167
- parts.shift
168
- return find_on_parts(request, parts, params)
169
173
  end
170
174
  end
171
175
  if request_node
@@ -108,6 +108,7 @@ class HttpRouter
108
108
  @conditions.key?(k) ?
109
109
  @conditions[k] << v :
110
110
  @conditions[k] = Array(v)
111
+ @conditions[k].flatten!
111
112
  end
112
113
  self
113
114
  end
@@ -304,7 +305,7 @@ class HttpRouter
304
305
  scan_regex = if next_index == part_segments.size
305
306
  matcher || /^[^\/]+/
306
307
  else
307
- /^#{matcher || '.*?'}(?=#{Regexp.quote(part_segments[next_index])})/
308
+ /^#{matcher || '[^\/]*?'}(?=#{Regexp.quote(part_segments[next_index])})/
308
309
  end
309
310
  router.variable(v_name, scan_regex)
310
311
  else
@@ -80,7 +80,7 @@ describe "HttpRouter route dispatching" do
80
80
  describe "get" do
81
81
  before(:each) do
82
82
  route_set.reset!
83
- route_set.get('/sample').to(@app)
83
+ route_set.get('/sample').head.to(@app)
84
84
  end
85
85
 
86
86
  it "should dispatch a GET request" do
@@ -89,7 +89,6 @@ describe "HttpRouter route dispatching" do
89
89
  end
90
90
 
91
91
  it "should dispatch a HEAD request" do
92
- pending
93
92
  response = route_set.call_with_mock_request("/sample", "HEAD")
94
93
  response.body.should eql("Hello World!")
95
94
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: http_router
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 17
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 2
10
- version: 0.2.2
9
+ - 3
10
+ version: 0.2.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Joshua Hull
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-05-30 00:00:00 +09:00
18
+ date: 2010-05-30 00:00:00 -04:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency