rack-accept-header-updater 1.0.1 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0
|
1
|
+
1.1.0
|
@@ -34,8 +34,8 @@ module Rack
|
|
34
34
|
unless (ext = ::File.extname(req.path_info)).empty?
|
35
35
|
if (mime_type = Rack::Mime::MIME_TYPES[ext.downcase])
|
36
36
|
env['HTTP_ACCEPT'] = [mime_type, env['HTTP_ACCEPT']].join(",")
|
37
|
+
req.path_info.gsub!(/#{ext}$/, '')
|
37
38
|
end
|
38
|
-
req.path_info.gsub!(/#{ext}$/, '')
|
39
39
|
end
|
40
40
|
@app.call(env)
|
41
41
|
end
|
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{rack-accept-header-updater}
|
8
|
-
s.version = "1.0
|
8
|
+
s.version = "1.1.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Cyril Rohr"]
|
12
|
-
s.date = %q{2009-10-
|
12
|
+
s.date = %q{2009-10-22}
|
13
13
|
s.description = %q{A Rack middleware for automatically removing file extensions from URIs, and update the Accept HTTP Header accordingly.}
|
14
14
|
s.email = %q{cyril.rohr@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -16,12 +16,6 @@ describe Rack::AcceptHeaderUpdater do
|
|
16
16
|
status, headers, body = Rack::AcceptHeaderUpdater.new(app).call(request)
|
17
17
|
body.should == ["application/json,*/*|/some/resource"]
|
18
18
|
end
|
19
|
-
it "should remove the file extension even if there are no mime types associated" do
|
20
|
-
app = lambda { |env| [200, {'Content-Type' => 'text/plain'}, [[env['HTTP_ACCEPT'], env['PATH_INFO']].join("|")]] }
|
21
|
-
request = Rack::MockRequest.env_for("/some/resource.json", :input => "foo=bar", 'HTTP_ACCEPT' => '*/*')
|
22
|
-
status, headers, body = Rack::AcceptHeaderUpdater.new(app).call(request)
|
23
|
-
body.should == ["*/*|/some/resource"]
|
24
|
-
end
|
25
19
|
it "should be case insensitive for extensions" do
|
26
20
|
mime :json, 'application/json'
|
27
21
|
app = lambda { |env| [200, {'Content-Type' => 'text/plain'}, [[env['HTTP_ACCEPT'], env['PATH_INFO']].join("|")]] }
|
@@ -42,5 +36,11 @@ describe Rack::AcceptHeaderUpdater do
|
|
42
36
|
status, headers, body = Rack::AcceptHeaderUpdater.new(app).call(request)
|
43
37
|
body.should == ["application/vnd.com.example.Collection+json;level=1,*/*|/some/resource"]
|
44
38
|
end
|
39
|
+
it "should not remove the extension if it is not registered in the rack mime types" do
|
40
|
+
app = lambda { |env| [200, {'Content-Type' => 'text/plain'}, [[env['HTTP_ACCEPT'], env['PATH_INFO']].join("|")]] }
|
41
|
+
request = Rack::MockRequest.env_for("/some/resource.x.y", :input => "foo=bar", 'HTTP_ACCEPT' => '*/*')
|
42
|
+
status, headers, body = Rack::AcceptHeaderUpdater.new(app).call(request)
|
43
|
+
body.should == ["*/*|/some/resource.x.y"]
|
44
|
+
end
|
45
45
|
end
|
46
46
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-accept-header-updater
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cyril Rohr
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-10-
|
12
|
+
date: 2009-10-22 00:00:00 +02:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|