class FixMicrosoftLinks::Rack::Response
Constants
- EXCLUDE_USER_AGENTS_REGEX
- USER_AGENTS_REGEX
Public Class Methods
new(app)
click to toggle source
# File lib/fix_microsoft_links.rb, line 7 def initialize(app) @app = app end
Public Instance Methods
call(env)
click to toggle source
# File lib/fix_microsoft_links.rb, line 11 def call(env) # Clicking a URL from Microsoft apps will redirect you to login to already authenticated sites otherwise :( # http://support.microsoft.com/kb/899927 if matching_user_agent?(env["HTTP_USER_AGENT"]) body = StringIO.new("<html><head><meta http-equiv='refresh' content='0'/></head><body></body></html>") return [200, {"Content-Type" => "text/html"}, body] end @app.call(env) end
matching_user_agent?(user_agent)
click to toggle source
# File lib/fix_microsoft_links.rb, line 21 def matching_user_agent?(user_agent) (user_agent =~ USER_AGENTS_REGEX) && !(user_agent =~ EXCLUDE_USER_AGENTS_REGEX) end