Sha256: 64640e2913f75a7fd9342d31950dabdf4d6cc439d89fc300463af0b2cc6f0544

Contents?: true

Size: 577 Bytes

Versions: 1

Compression:

Stored size: 577 Bytes

Contents

module Rack
  class NoIE6
    def initialize(app, options = {})
      @app = app
      @options = options
      @options[:redirect] ||= 'http://www.microsoft.com/windows/internet-explorer/default.aspx'
    end

    def call(env)
      ie6_found_in?(env) ? kick_it : @app.call(env)    
    end

    private
    def ie6_found_in?(env)
      if env['HTTP_USER_AGENT']
        env['HTTP_USER_AGENT'][/MSIE 6.0/] and @options[:redirect] != env['PATH_INFO']
      end
    end

    def kick_it
      [301, {'Location' => @options[:redirect]}, 'Fail browser is fail']
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sant0sk1-rack-noie6-1.0.1 lib/noie6.rb