fix_microsoft_links 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,7 @@
1
1
  module FixMicrosoftLinks
2
2
  class Railtie < Rails::Railtie
3
3
  initializer 'fix_microsoft_links.register_middleware' do |app|
4
- app.config.middleware.insert_after ::Rack::Lock, FixMicrosoftLinks::Rack::Response
4
+ app.config.middleware.use FixMicrosoftLinks::Rack::Response
5
5
  end
6
6
  end
7
7
  end
@@ -1,6 +1,8 @@
1
1
  module FixMicrosoftLinks
2
2
  module Rack
3
3
  class Response
4
+ USER_AGENTS_REGEX = /[^\w](Word|Excel|PowerPoint|ms-office)([^\w]|\z)/
5
+
4
6
  def initialize(app)
5
7
  @app = app
6
8
  end
@@ -8,7 +10,7 @@ module FixMicrosoftLinks
8
10
  def call(env)
9
11
  # Clicking a URL from Microsoft apps will redirect you to login to already authenticated sites otherwise :(
10
12
  # http://support.microsoft.com/kb/899927
11
- if env["HTTP_USER_AGENT"] =~ /[^\w](Word|Excel|PowerPoint|ms-office)([^\w]|\z)/
13
+ if env["HTTP_USER_AGENT"] =~ USER_AGENTS_REGEX
12
14
  body = StringIO.new("<html><head><meta http-equiv='refresh' content='0'/></head><body></body></html>")
13
15
  return [200, {"Content-Type" => "text/html"}, body]
14
16
  end
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.2
4
+ version: 0.1.3
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: 2012-05-17 00:00:00.000000000 Z
13
+ date: 2013-07-16 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rack
17
- requirement: !ruby/object:Gem::Requirement
17
+ requirement: &70100860433260 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ! '>='
@@ -22,12 +22,7 @@ dependencies:
22
22
  version: 1.1.1
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: !ruby/object:Gem::Requirement
26
- none: false
27
- requirements:
28
- - - ! '>='
29
- - !ruby/object:Gem::Version
30
- version: 1.1.1
25
+ version_requirements: *70100860433260
31
26
  description:
32
27
  email:
33
28
  executables: []
@@ -57,7 +52,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
57
52
  version: '0'
58
53
  requirements: []
59
54
  rubyforge_project:
60
- rubygems_version: 1.8.24
55
+ rubygems_version: 1.8.15
61
56
  signing_key:
62
57
  specification_version: 3
63
58
  summary: Fixes redirects to login pages when a user clicks a link to your site from