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 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.6'
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
@@ -1,6 +1,12 @@
1
1
  # run me with:
2
2
  # $rackup examples/app.ru -p 3000
3
3
  #
4
+ # and try different url extensions:
5
+ # localhost:3000/foo.html
6
+ # localhost:3000/foo.xml
7
+ # localhost:3000/foo.txt
8
+ # ...
9
+ #
4
10
  require 'pathname'
5
11
  require 'rubygems'
6
12
  require 'rack'
@@ -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.6
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-03 00:00:00 -04:00
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.6
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-02 21:00:00 -07:00
12
+ date: 2009-06-07 21:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15