Skip to content

Commit

Permalink
Merge pull request #79 from BotyglotTeam/improve-support-for-linkedinbot
Browse files Browse the repository at this point in the history
Add support for LinkedInBot
  • Loading branch information
did committed Apr 5, 2024
2 parents 302e7f6 + 087afe8 commit c820507
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/maglev/preview_constraint.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

module Maglev
class PreviewConstraint
CRAWLER_USER_AGENTS = /Googlebot|Twitterbot|facebookexternalhit/o.freeze
CRAWLER_USER_AGENTS = /Googlebot|Twitterbot|facebookexternalhit|LinkedInBot/o.freeze

attr_reader :preview_host

Expand Down
12 changes: 10 additions & 2 deletions spec/requests/maglev/page_preview_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
expect(response.body).to include('--basic-theme-primary-color: #F87171;')
end

describe 'Given Facebook/Google/Twitter crawl the index page' do
describe 'Given Facebook/Google/Twitter/LinkedIn crawl the index page' do
# rubocop:disable Style/StringHashKeys
let(:headers) { { 'HTTP_CONTENT_TYPE' => '*/*', 'HTTP_ACCEPT' => '*/*', 'HTTP_USER_AGENT' => user_agent } }
# rubocop:enable Style/StringHashKeys
Expand All @@ -59,13 +59,21 @@
end
end

describe 'Given Twitter crawls it' do
describe 'Given Google crawls it' do
let(:user_agent) { 'Googlebot/2.1' }
it 'renders the index page' do
get '/index', headers: headers
expect(response.body).to include('<title>Default - Home</title>')
end
end

describe 'Given LinkedIn crawls it' do
let(:user_agent) { 'LinkedInBot/1.0' }
it 'renders the index page' do
get '/index', headers: headers
expect(response.body).to include('<title>Default - Home</title>')
end
end
end
end

Expand Down

0 comments on commit c820507

Please sign in to comment.