phorsfall-tidy_rack 0.1.0 → 0.2.0

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.
@@ -1,4 +1,4 @@
1
1
  ---
2
- :minor: 1
2
+ :minor: 2
3
3
  :patch: 0
4
4
  :major: 0
@@ -7,7 +7,7 @@ class TidyRack
7
7
 
8
8
  def call(env)
9
9
  status, headers, response = @app.call(env)
10
- if headers['Content-Type'].include?('text/html')
10
+ if /text\/html/o.match(headers['Content-Type'])
11
11
  response = tidy(response)
12
12
  headers['Content-Length'] = response.size.to_s
13
13
  end
@@ -12,17 +12,24 @@ class TidyRackTest < Test::Unit::TestCase
12
12
  eof
13
13
  end
14
14
 
15
- should "include the HTML Tidy generated meta tag" do
15
+ should "tidy html responses" do
16
16
  app = lambda { |env| [200, { 'Content-Type' => 'text/html' }, html] }
17
17
  status, headers, response = TidyRack.new(app).call({})
18
18
  doc = Hpricot(response)
19
19
  assert doc.at('meta[@content*="HTML Tidy"]')
20
20
  end
21
21
 
22
- should "only tidy html responses" do
22
+ should "not tidy plain text responses" do
23
23
  app = lambda { |env| [200, { 'Content-Type' => 'text/plain' }, html] }
24
24
  status, headers, response = TidyRack.new(app).call({})
25
25
  doc = Hpricot(response)
26
26
  assert_nil doc.at('meta[@content*="HTML Tidy"]')
27
27
  end
28
+
29
+ should "not die when content-type is nil" do
30
+ app = lambda { |env| [200, {}, html] }
31
+ status, headers, response = TidyRack.new(app).call({})
32
+ doc = Hpricot(response)
33
+ assert_nil doc.at('meta[@content*="HTML Tidy"]')
34
+ end
28
35
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: phorsfall-tidy_rack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paul Horsfall