Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions lib/prerender_rails.rb
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ def initialize(app, options={})
'.rar',
'.exe',
'.wmv',
'.doc',
'.avi',
'.ppt',
'.mpg',
Expand All @@ -136,7 +135,16 @@ def initialize(app, options={})
'.iso',
'.flv',
'.m4v',
'.torrent'
'.torrent',
'.ttf',
'.otf',
'.woff',
'.woff2',
'.eot',
'.svg',
'.webp',
'.avif',
'.webmanifest'
]

@options = options
Expand Down
8 changes: 8 additions & 0 deletions test/lib/prerender_rails.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,14 @@
end


it "should continue to app routes if user is a bot, but the bot is requesting a font file" do
request = Rack::MockRequest.env_for "/fonts/inter.woff2", "HTTP_USER_AGENT" => bot
response = Rack::Prerender.new(@app).call(request)

assert_equal "", response[2]
end


it "should continue to app routes if the url is not part of the regex specific whitelist" do
request = Rack::MockRequest.env_for "/saved/search/blah?_escaped_fragment_=", "HTTP_USER_AGENT" => bot
response = Rack::Prerender.new(@app, whitelist: ['^/search', '/help']).call(request)
Expand Down