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 +4 -4
- data/lib/prerender_rails.rb +4 -4
- data/prerender_rails.gemspec +1 -1
- data/test/lib/prerender_rails.rb +6 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0dab2fb1c0fb1a232b5901dde71f986ca4000c65
|
4
|
+
data.tar.gz: 675b2dfbdede57ad5f448377aa964e304f5fea30
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 748be26bea44cae70d7c0f5197f1e54aeede93c8951868e70d5acc7d6a620fb86deac649a8a71b4bd07c81e26ab73af9b79c09316e5362ec8a0d60afaa35bfc2
|
7
|
+
data.tar.gz: e34eb14973e15ec46bbbf9214aaad0bc688a8d9edc58b4148ec8828d2d447d55700bd7b0ebf7f8c8af56138340d1510a8d070bc7eba6379dd3dbc3b6e4293b5c
|
data/lib/prerender_rails.rb
CHANGED
@@ -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.
|
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.
|
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.
|
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
|
data/prerender_rails.gemspec
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |spec|
|
4
4
|
spec.name = "prerender_rails"
|
5
|
-
spec.version = "1.
|
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}
|
data/test/lib/prerender_rails.rb
CHANGED
@@ -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.
|
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:
|
11
|
+
date: 2016-02-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|