prerender_rails 0.1.14 → 0.1.15

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ecf7a38c64f481c20b394e6bc5044eff1233395e
4
- data.tar.gz: c0308f0a13f9dbb3d551ffa55de2bdbe30249537
3
+ metadata.gz: 0c5a0e13a7ff92ef76e7f5ff2deb051f59813548
4
+ data.tar.gz: 51e0c17346bb5edf7cb1cc9c386fd6cdb75243b0
5
5
  SHA512:
6
- metadata.gz: dccc5aac455510547500c0c271fa45ad0ff5e0fc3a551a91c60e4db29524cbe2da91199983b406bec0af9753fca1b96126b9b104aabea8565d97c8f80c899896
7
- data.tar.gz: 95804e50b88d5571d4cf8429789599b405eb89d6b637ebaa034dc3168e562fb058f965f865ea4512ac4993cc7b6f37d78da8c46e28a0a8128b1f3e97cd03305c
6
+ metadata.gz: f56d9caa703f77b84fa2b875545e57fc6689529bb37a5a539a74a9ea5cbe17dc0badcd80064d4dc6196931a59afef112b8247de07c73b46e34fa4fd75902f83f
7
+ data.tar.gz: 2b3b92b91d2c8f9bc65c69826c122983206363618584019a49a4529760db02aab6b7b48ed6cb0550f71ac039dcb19b962ffabd15ebb561cdcc902aa58bd9ee56
@@ -89,15 +89,17 @@ module Rack
89
89
 
90
90
  def should_show_prerendered_page(env)
91
91
  user_agent = env['HTTP_USER_AGENT']
92
+ is_requesting_prerendered_page = false
93
+
92
94
  return false if !user_agent
93
95
  return false if env['REQUEST_METHOD'] != 'GET'
94
96
 
95
97
  request = Rack::Request.new(env)
96
98
 
97
- return true if Rack::Utils.parse_query(request.query_string).has_key?('_escaped_fragment_')
99
+ is_requesting_prerendered_page = true if Rack::Utils.parse_query(request.query_string).has_key?('_escaped_fragment_')
98
100
 
99
- #if it is not a bot...dont prerender
100
- return false if @crawler_user_agents.all? { |crawler_user_agent| !user_agent.downcase.include?(crawler_user_agent.downcase) }
101
+ #if it is a bot...show prerendered page
102
+ is_requesting_prerendered_page = true if @crawler_user_agents.any? { |crawler_user_agent| user_agent.downcase.include?(crawler_user_agent.downcase) }
101
103
 
102
104
  #if it is a bot and is requesting a resource...dont prerender
103
105
  return false if @extensions_to_ignore.any? { |extension| request.path.include? extension }
@@ -119,7 +121,7 @@ module Rack
119
121
  return false
120
122
  end
121
123
 
122
- return true
124
+ return is_requesting_prerendered_page
123
125
  end
124
126
 
125
127
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = "prerender_rails"
5
- spec.version = "0.1.14"
5
+ spec.version = "0.1.15"
6
6
  spec.authors = ["Todd Hooper"]
7
7
  spec.email = ["todd@collectiveip.com"]
8
8
  spec.description = %q{Rails middleware to prerender your javascript heavy pages on the fly by a phantomjs service}
@@ -67,7 +67,7 @@ describe Rack::Prerender do
67
67
 
68
68
 
69
69
  it "should continue to app routes if the url is not part of the regex specific whitelist" do
70
- request = Rack::MockRequest.env_for "/saved/search/blah", "HTTP_USER_AGENT" => bot
70
+ request = Rack::MockRequest.env_for "/saved/search/blah?_escaped_fragment_=", "HTTP_USER_AGENT" => bot
71
71
  response = Rack::Prerender.new(@app, whitelist: ['^/search', '/help']).call(request)
72
72
 
73
73
  assert_equal "", response[2]
@@ -75,7 +75,7 @@ describe Rack::Prerender do
75
75
 
76
76
 
77
77
  it "should return a prerendered response if the url is part of the regex specific whitelist" do
78
- request = Rack::MockRequest.env_for "/search/things/123/page", "HTTP_USER_AGENT" => bot
78
+ request = Rack::MockRequest.env_for "/search/things/123/page?_escaped_fragment_=", "HTTP_USER_AGENT" => bot
79
79
  stub_request(:get, @prerender.build_api_url(request)).to_return(:body => "<html></html>")
80
80
  response = Rack::Prerender.new(@app, whitelist: ['^/search.*page', '/help']).call(request)
81
81
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: prerender_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.14
4
+ version: 0.1.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Todd Hooper