prerender_rails 1.2.0 → 1.3.0

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: 3ee24bb70559470ecc22d9d53d4f25cea8d4919e
4
- data.tar.gz: 23ba68c813c0fb612dce060dc80c1f63de794192
3
+ metadata.gz: 0dab2fb1c0fb1a232b5901dde71f986ca4000c65
4
+ data.tar.gz: 675b2dfbdede57ad5f448377aa964e304f5fea30
5
5
  SHA512:
6
- metadata.gz: e67ad893ffd7b2a1976076425fb9cb6750c893e2b316a9016438b74d262231d7f48ff1ad6e272ba646cfb03cedc39a59702d36073e30b0808e12a65a9292a712
7
- data.tar.gz: b71f81d28e7e98e43101783e408d38851a26c3fd0831a6d80e8ad81373207b03dfe28342468cb06142b16061b7b61e224902066d514ed75d76e76c3a9d47aca5
6
+ metadata.gz: 748be26bea44cae70d7c0f5197f1e54aeede93c8951868e70d5acc7d6a620fb86deac649a8a71b4bd07c81e26ab73af9b79c09316e5362ec8a0d60afaa35bfc2
7
+ data.tar.gz: e34eb14973e15ec46bbbf9214aaad0bc688a8d9edc58b4148ec8828d2d447d55700bd7b0ebf7f8c8af56138340d1510a8d070bc7eba6379dd3dbc3b6e4293b5c
@@ -121,10 +121,10 @@ module Rack
121
121
  is_requesting_prerendered_page = true if buffer_agent
122
122
 
123
123
  #if it is a bot and is requesting a resource...dont prerender
124
- return false if @extensions_to_ignore.any? { |extension| request.path.include? extension }
124
+ return false if @extensions_to_ignore.any? { |extension| request.fullpath.include? extension }
125
125
 
126
126
  #if it is a bot and not requesting a resource and is not whitelisted...dont prerender
127
- return false if @options[:whitelist].is_a?(Array) && @options[:whitelist].all? { |whitelisted| !Regexp.new(whitelisted).match(request.path) }
127
+ return false if @options[:whitelist].is_a?(Array) && @options[:whitelist].all? { |whitelisted| !Regexp.new(whitelisted).match(request.fullpath) }
128
128
 
129
129
  #if it is a bot and not requesting a resource and is not blacklisted(url or referer)...dont prerender
130
130
  if @options[:blacklist].is_a?(Array) && @options[:blacklist].any? { |blacklisted|
@@ -132,7 +132,7 @@ module Rack
132
132
  blacklistedReferer = false
133
133
  regex = Regexp.new(blacklisted)
134
134
 
135
- blacklistedUrl = !!regex.match(request.path)
135
+ blacklistedUrl = !!regex.match(request.fullpath)
136
136
  blacklistedReferer = !!regex.match(request.referer) if request.referer
137
137
 
138
138
  blacklistedUrl || blacklistedReferer
@@ -212,7 +212,7 @@ module Rack
212
212
  cached_render = @options[:before_render].call(env)
213
213
 
214
214
  if cached_render && cached_render.is_a?(String)
215
- Rack::Response.new(cached_render, 200, [])
215
+ Rack::Response.new(cached_render, 200, { 'Content-Type' => 'text/html; charset=utf-8' })
216
216
  elsif cached_render && cached_render.is_a?(Rack::Response)
217
217
  cached_render
218
218
  else
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = "prerender_rails"
5
- spec.version = "1.2.0"
5
+ spec.version = "1.3.0"
6
6
  spec.authors = ["Todd Hooper"]
7
7
  spec.email = ["todd@prerender.io"]
8
8
  spec.description = %q{Rails middleware to prerender your javascript heavy pages on the fly by a phantomjs service}
@@ -90,6 +90,12 @@ describe Rack::Prerender do
90
90
  assert_equal "", response[2]
91
91
  end
92
92
 
93
+ it "should continue to app routes if the hashbang url is part of the regex specific blacklist" do
94
+ request = Rack::MockRequest.env_for "?_escaped_fragment_=/search/things/123/page", "HTTP_USER_AGENT" => bot
95
+ response = Rack::Prerender.new(@app, blacklist: ['/search', '/help']).call(request)
96
+
97
+ assert_equal "", response[2]
98
+ end
93
99
 
94
100
  it "should return a prerendered response if the url is not part of the regex specific blacklist" do
95
101
  request = Rack::MockRequest.env_for "/profile/search/blah", "HTTP_USER_AGENT" => bot
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: 1.2.0
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Todd Hooper
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-17 00:00:00.000000000 Z
11
+ date: 2016-02-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack