prerender_rails 0.1.1 → 0.1.2

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: e3c894d1d1e5df79df9e1cf0eebafd1f1a9cf594
4
- data.tar.gz: 4426e9be4a4d0a1550dad665b379da484786586e
3
+ metadata.gz: fffaf338614d81a13df75539ed9de2fc2f63fcea
4
+ data.tar.gz: 94b5487d1000a7caaec217c920a5ec0c9a56a5d3
5
5
  SHA512:
6
- metadata.gz: 03efbb30411757b067c8fa75b3173b159fd4699883f80e82fbdc774b074c955c5949a4d664c454d4afa6f213f045580cb75d35f51c82198e4173cb014edc1f8d
7
- data.tar.gz: 8ca4e9d871fbc8763a2a7822055731747897e8937d06b15f323899e78de65df19490b50da6b97948afef02f7af5e6c393a909d44a661a34c241a84e05a365707
6
+ metadata.gz: 3d75bdcd348a45c45502d0d7632329717185b730ecae77f536c304421fc8777fcd64a5c392df13d2f1e7b32303a9fb93265f377594bd0cc30d4cea8cf47176d5
7
+ data.tar.gz: 82898b819d8bcc33a2e04f5da1f05da53641c5a1c3d4bcadbfc614286989f063a8a3ad85d0d5b3705b1ed105ed72415c73b36c5103c7282065552ab6b1de3011
@@ -79,7 +79,7 @@ module Rack
79
79
 
80
80
  request = Rack::Request.new(env)
81
81
 
82
- return true if request.query_string.include? '_escaped_fragment_'
82
+ return true if Rack::Utils.parse_query(request.query_string).has_key?('_escaped_fragment_')
83
83
 
84
84
  #if it is not a bot...dont prerender
85
85
  return false if @crawler_user_agents.all? { |crawler_user_agent| !user_agent.downcase.include?(crawler_user_agent.downcase) }
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = "prerender_rails"
5
- spec.version = "0.1.1"
5
+ spec.version = "0.1.2"
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}
@@ -22,13 +22,20 @@ describe Rack::Prerender do
22
22
  end
23
23
 
24
24
  it "should return a prerendered reponse if user is a bot by checking for _escaped_fragment_" do
25
- request = Rack::MockRequest.env_for "/path?_escaped_fragment_=yes", "HTTP_USER_AGENT" => user
25
+ request = Rack::MockRequest.env_for "/path?_escaped_fragment_=", "HTTP_USER_AGENT" => user
26
26
  stub_request(:get, @prerender.build_api_url(request)).to_return(:body => "<html></html>")
27
27
  response = Rack::Prerender.new(@app).call(request)
28
28
 
29
29
  assert_equal response[2].body, ["<html></html>"]
30
30
  end
31
31
 
32
+ it "should continue to app routes if the url is a bad url with _escaped_fragment_" do
33
+ request = Rack::MockRequest.env_for "/path?query=string?_escaped_fragment_=", "HTTP_USER_AGENT" => user
34
+ response = Rack::Prerender.new(@app).call(request)
35
+
36
+ assert_equal response[2], ""
37
+ end
38
+
32
39
  it "should continue to app routes if user is not a bot by checking agent string" do
33
40
  request = Rack::MockRequest.env_for "/", "HTTP_USER_AGENT" => user
34
41
  response = Rack::Prerender.new(@app).call(request)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: prerender_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Todd Hooper
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-13 00:00:00.000000000 Z
11
+ date: 2013-10-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack