mynyml-rack-abstract-format 0.9.6 → 0.9.7
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -1
- data/examples/app.ru +6 -0
- data/lib/rack/abstract_format.rb +2 -2
- data/rack-abstract-format.gemspec +2 -2
- data/test/test_abstract_format.rb +5 -0
- metadata +2 -2
data/Rakefile
CHANGED
@@ -22,7 +22,7 @@ end
|
|
22
22
|
|
23
23
|
spec = Gem::Specification.new do |s|
|
24
24
|
s.name = 'rack-abstract-format'
|
25
|
-
s.version = '0.9.
|
25
|
+
s.version = '0.9.7'
|
26
26
|
s.summary = "Rack middleware that abstracts format (extension) away from the path (into env)"
|
27
27
|
s.description = "Rack middleware that abstracts format (extension) away from the path (into env)"
|
28
28
|
s.author = "Martin Aumont"
|
data/examples/app.ru
CHANGED
data/lib/rack/abstract_format.rb
CHANGED
@@ -10,7 +10,7 @@ module Rack
|
|
10
10
|
def call(env)
|
11
11
|
path = Pathname(env['PATH_INFO'])
|
12
12
|
env['PATH_INFO'] = path.to_s.sub(/#{path.extname}$/,'')
|
13
|
-
env['HTTP_ACCEPT'] = concat(env['HTTP_ACCEPT'], Rack::Mime.mime_type(path.extname))
|
13
|
+
env['HTTP_ACCEPT'] = concat(env['HTTP_ACCEPT'], Rack::Mime.mime_type(path.extname, nil))
|
14
14
|
@app.call(env)
|
15
15
|
end
|
16
16
|
|
@@ -21,7 +21,7 @@ module Rack
|
|
21
21
|
# ["application/xml", "text/html", "application/xhtml+xml", "application/xml;q=0.9", "*/*;q=0.8"]
|
22
22
|
#
|
23
23
|
def concat(accept, type)
|
24
|
-
(accept || '').split(',').unshift(type).join(',')
|
24
|
+
(accept || '').split(',').unshift(type).compact.join(',')
|
25
25
|
end
|
26
26
|
end
|
27
27
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-abstract-format
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Martin Aumont
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-06-
|
12
|
+
date: 2009-06-08 00:00:00 -04:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -28,4 +28,9 @@ class AbstractFormatTest < Test::Unit::TestCase
|
|
28
28
|
env = get('/path/resource.html', 'HTTP_ACCEPT' => 'application/xml')
|
29
29
|
assert_equal 'text/html,application/xml' , env['HTTP_ACCEPT']
|
30
30
|
end
|
31
|
+
|
32
|
+
test "url without extension" do
|
33
|
+
env = get('/path/resource', 'HTTP_ACCEPT' => 'text/html')
|
34
|
+
assert_equal 'text/html' , env['HTTP_ACCEPT']
|
35
|
+
end
|
31
36
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mynyml-rack-abstract-format
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Martin Aumont
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-06-
|
12
|
+
date: 2009-06-07 21:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|