rack-noindex_https 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,5 @@
1
1
  module Rack
2
2
  class NoindexHttps
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.2"
4
4
  end
5
5
  end
@@ -14,7 +14,7 @@ module Rack
14
14
  @status, @headers, @body = @app.call(env)
15
15
  request = Rack::Request.new(env)
16
16
 
17
- if request.scheme == 'https' && @headers['Content-Type'] == 'application/html'
17
+ if request.scheme == 'https' && (@headers['Content-Type'] =~ /application\/html/ || @headers['Content-Type'] =~ /text\/html/)
18
18
  @body = @body.collect {|fragement| fragement.gsub(%r{</head>}, '<meta name="robots" content="noindex"></head>') }
19
19
  end
20
20
 
@@ -7,6 +7,10 @@ module Rack
7
7
  get('https://example.org/').body.should == '<html><head>Hello world<meta name="robots" content="noindex"></head><body></body></html>'
8
8
  end
9
9
 
10
+ it 'should inject no index tag into head of https HTML request for text/html' do
11
+ get('https://example.org/text.html').body.should == '<html><head>Hello world<meta name="robots" content="noindex"></head><body></body></html>'
12
+ end
13
+
10
14
  it 'should not inject no index tag of http HTML request' do
11
15
  get('/').body.should == '<html><head>Hello world</head><body></body></html>'
12
16
  end
data/spec/spec_helper.rb CHANGED
@@ -10,7 +10,9 @@ def main_app
10
10
  request = Rack::Request.new(env)
11
11
  case request.path
12
12
  when '/' then
13
- [200, {'Content-Type' => 'application/html'}, ['<html><head>Hello world</head><body></body></html>']]
13
+ [200, {'Content-Type' => 'application/html; charset=utf-8'}, ['<html><head>Hello world</head><body></body></html>']]
14
+ when '/text.html' then
15
+ [200, {'Content-Type' => ' text/html; charset=utf-8'}, ['<html><head>Hello world</head><body></body></html>']]
14
16
  when '/test.xml' then
15
17
  [200, {'Content-Type' => 'application/xml'}, ['<head></head><xml></xml>']]
16
18
  when '/bob' then
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-noindex_https
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: