fix_microsoft_links 0.1.3 → 0.1.4

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.
Files changed (2) hide show
  1. data/lib/fix_microsoft_links.rb +11 -5
  2. metadata +6 -5
@@ -2,20 +2,26 @@ module FixMicrosoftLinks
2
2
  module Rack
3
3
  class Response
4
4
  USER_AGENTS_REGEX = /[^\w](Word|Excel|PowerPoint|ms-office)([^\w]|\z)/
5
+ EXCLUDE_USER_AGENTS_REGEX = /Microsoft Outlook/
5
6
 
6
- def initialize(app)
7
- @app = app
8
- end
7
+ def initialize(app)
8
+ @app = app
9
+ end
9
10
 
10
11
  def call(env)
11
12
  # Clicking a URL from Microsoft apps will redirect you to login to already authenticated sites otherwise :(
12
13
  # http://support.microsoft.com/kb/899927
13
- if env["HTTP_USER_AGENT"] =~ USER_AGENTS_REGEX
14
+ if matching_user_agent?(env["HTTP_USER_AGENT"])
14
15
  body = StringIO.new("<html><head><meta http-equiv='refresh' content='0'/></head><body></body></html>")
15
16
  return [200, {"Content-Type" => "text/html"}, body]
16
17
  end
17
18
  @app.call(env)
18
19
  end
20
+
21
+ def matching_user_agent?(user_agent)
22
+ (user_agent =~ USER_AGENTS_REGEX) && !(user_agent =~ EXCLUDE_USER_AGENTS_REGEX)
23
+ end
24
+
19
25
  end
20
26
  end
21
27
  end
@@ -25,4 +31,4 @@ require 'fix_microsoft_links/railtie' if defined?(Rails) && defined?(Rails::Rail
25
31
 
26
32
  # If you are running a pre-rails 3 app you will need to do something like the following in your environment.rb:
27
33
  # require 'fix_microsoft_links'
28
- # config.middleware.insert_after Rack::Lock, FixMicrosoftLinks::Rack::Response
34
+ # config.middleware.insert_after Rack::Lock, FixMicrosoftLinks::Rack::Response
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fix_microsoft_links
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,11 +10,11 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-07-16 00:00:00.000000000 Z
13
+ date: 2013-08-21 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rack
17
- requirement: &70100860433260 !ruby/object:Gem::Requirement
17
+ requirement: &70278371879040 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ! '>='
@@ -22,7 +22,7 @@ dependencies:
22
22
  version: 1.1.1
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *70100860433260
25
+ version_requirements: *70278371879040
26
26
  description:
27
27
  email:
28
28
  executables: []
@@ -33,7 +33,8 @@ files:
33
33
  - lib/fix_microsoft_links.rb
34
34
  - lib/fix_microsoft_links/railtie.rb
35
35
  homepage: https://github.com/spilliton/fix_microsoft_links
36
- licenses: []
36
+ licenses:
37
+ - MIT
37
38
  post_install_message:
38
39
  rdoc_options: []
39
40
  require_paths: