strelka 0.0.1.pre.290 → 0.0.1.pre.291
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data.tar.gz.sig +0 -0
- data/lib/strelka/httprequest.rb +6 -6
- data/spec/strelka/httprequest_spec.rb +27 -0
- data/spec/strelka/router/default_spec.rb +5 -0
- metadata +1 -1
- metadata.gz.sig +2 -1
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/strelka/httprequest.rb
CHANGED
@@ -94,13 +94,13 @@ class Strelka::HTTPRequest < Mongrel2::HTTPRequest
|
|
94
94
|
### # => #<URI::HTTP:0x007fe34d16b2e0 URL:http://localhost:8080/user>
|
95
95
|
def base_uri
|
96
96
|
rval = self.uri
|
97
|
-
rval.path = self.
|
97
|
+
rval.path = self.headers.pattern
|
98
98
|
rval.query = nil
|
99
99
|
return rval
|
100
100
|
end
|
101
101
|
|
102
102
|
|
103
|
-
### Return the portion of the Request's path that was routed by Mongrel2. This and the
|
103
|
+
### Return the unescaped portion of the Request's path that was routed by Mongrel2. This and the
|
104
104
|
### #app_path make up the #path.
|
105
105
|
###
|
106
106
|
### # For a handler with a route of '/user', for the request:
|
@@ -108,20 +108,20 @@ class Strelka::HTTPRequest < Mongrel2::HTTPRequest
|
|
108
108
|
### request.route
|
109
109
|
### # => "/user"
|
110
110
|
def route
|
111
|
-
return self.headers.pattern
|
111
|
+
return URI.unescape( self.headers.pattern )
|
112
112
|
end
|
113
113
|
alias_method :pattern, :route
|
114
114
|
|
115
115
|
|
116
|
-
### Return the portion of the Request's path relative to the request's #route.
|
116
|
+
### Return the unescaped portion of the Request's path relative to the request's #route.
|
117
117
|
###
|
118
118
|
### # For a handler with a route of '/user', for the request:
|
119
119
|
### # "GET /user/1/profile HTTP/1.1"
|
120
120
|
### request.app_path
|
121
121
|
### # => "/1/profile"
|
122
122
|
def app_path
|
123
|
-
rval = self.uri.path
|
124
|
-
rval.slice!( 0, self.route.
|
123
|
+
rval = URI.unescape( self.uri.path )
|
124
|
+
rval.slice!( 0, self.route.bytesize )
|
125
125
|
return rval
|
126
126
|
end
|
127
127
|
|
@@ -78,6 +78,33 @@ describe Strelka::HTTPRequest do
|
|
78
78
|
end
|
79
79
|
|
80
80
|
|
81
|
+
context "instance with URI-escaped characters in its path" do
|
82
|
+
|
83
|
+
before( :each ) do
|
84
|
+
@req = @request_factory.get( '/directory/user%20info/ged%00' )
|
85
|
+
end
|
86
|
+
|
87
|
+
it "knows what the request's parsed URI is" do
|
88
|
+
@req.uri.should be_a( URI )
|
89
|
+
@req.uri.to_s.should == 'http://localhost:8080/directory/user%20info/ged%00'
|
90
|
+
end
|
91
|
+
|
92
|
+
it "knows what Mongrel2 route it followed" do
|
93
|
+
@req.pattern.should == "/directory"
|
94
|
+
end
|
95
|
+
|
96
|
+
it "knows what the URI of the route handling the request is" do
|
97
|
+
@req.base_uri.should be_a( URI )
|
98
|
+
@req.base_uri.to_s.should == 'http://localhost:8080/directory'
|
99
|
+
end
|
100
|
+
|
101
|
+
it "knows what the path of the request past its route is" do
|
102
|
+
@req.app_path.should == "/user info/ged\0"
|
103
|
+
end
|
104
|
+
|
105
|
+
end
|
106
|
+
|
107
|
+
|
81
108
|
context "instance with a query string" do
|
82
109
|
|
83
110
|
before( :each ) do
|
@@ -258,6 +258,11 @@ describe Strelka::Router::Default do
|
|
258
258
|
@router.route_request( req ).should match_route( :as_pdf )
|
259
259
|
end
|
260
260
|
|
261
|
+
it "doesn't route /foo%1B.pdf to the regexp action" do
|
262
|
+
req = @request_factory.get( "/user/foo%1B.pdf" )
|
263
|
+
@router.route_request( req ).should_not match_route( :as_pdf )
|
264
|
+
end
|
265
|
+
|
261
266
|
it "routes /zanzibar.pdf to the regexp action" do
|
262
267
|
req = @request_factory.get( '/user/zanzibar.pdf' )
|
263
268
|
@router.route_request( req ).should match_route( :as_pdf )
|
metadata
CHANGED
metadata.gz.sig
CHANGED
@@ -1 +1,2 @@
|
|
1
|
-
|
1
|
+
�-�)E9�c"�މx� (���"�Jh���~�y�'c+���u�38�`�f���Q6��yV����c�K��0��0R�b�Hk#��M����aޟ˗�6�!}��a��9I�P�����U<���Y����a�ʑcf�ӱV�6��g� ��!�zؖ��o����7�Q��匋�>���N_Db��"�V bەD=�;�
|
2
|
+
�F*���\��f;�OeQK�?����l�g�ǔ;�@��+�Z}��e�;lM�
|