Class: Rack::NoindexHttps

Inherits:
Object
  • Object
show all
Defined in:
lib/rack-noindex_https.rb,
lib/rack-noindex_https/version.rb

Constant Summary collapse

VERSION =
"0.0.3"

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ NoindexHttps

Returns a new instance of NoindexHttps.



5
6
7
# File 'lib/rack-noindex_https.rb', line 5

def initialize(app)
  @app = app
end

Instance Method Details

#_call(env) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/rack-noindex_https.rb', line 13

def _call(env)
  puts "got here"
  @status, @headers, @body = @app.call(env)
  puts env.inspect
  request = Rack::Request.new(env)
  
  if request.scheme == 'https' && (@headers['Content-Type'] =~ /application\/html/ || @headers['Content-Type'] =~ /text\/html/)
    @body = @body.collect {|fragement| puts "updating"; fragement.gsub(%r{</head>}, '<meta name="robots" content="noindex"></head>') } 
  end

  puts 'finished'

  [@status, @headers, @body]
end

#call(env) ⇒ Object



9
10
11
# File 'lib/rack-noindex_https.rb', line 9

def call(env)
  dup._call(env)
end