Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed userAgentRegExps #46

Merged
merged 1 commit into from
Mar 5, 2017
Merged

Fixed userAgentRegExps #46

merged 1 commit into from
Mar 5, 2017

Conversation

RickvdP
Copy link
Contributor

@RickvdP RickvdP commented Mar 5, 2017

The previous regexes do not work for many of the bots.

For example the Google-Structured-Data-Testing-Tool sends a header value of Mozilla/5.0 (compatible; Google-Structured-Data-Testing-Tool +https://search.google.com/structured-data/testing-tool, which will not match the /^google-structured-data-testing-tool/i regex, as the ^ indicates that the regex will only match if the header begins with google-structured-data-testing-tool, which it obviously doesn't.

By removing the ^ operator from all RegEx patterns, the regex will match more loosely (and correctly) if the sent user agent header contains (one of) the strings from the User Agent RegEx array.

I've fixed it locally by overriding the userAgentRegExps like below, but I'd like to make sure nobody else is getting frustrated by Spiderable not serving the pre-rendered versions to some user agents :).

Spiderable.userAgentRegExps = [
	/facebookExternalHit/i,
	/linkedinBot/i,
	/twitterBot/i,
	/googleBot/i,
	/bingBot/i,
	/yandex/i,
	/google-structured-data-testing-tool/i,
	/yahoo/i,
	/MJ12Bot/i,
	/tweetmemeBot/i,
	/baiduSpider/i,
	/Mail\.RU_Bot/i,
	/ahrefsBot/i,
	/SiteLockSpider/i
];

@dr-dimitru dr-dimitru merged commit 28d6c66 into veliovgroup:master Mar 5, 2017
dr-dimitru added a commit that referenced this pull request Mar 16, 2017
 - Compatibility with `meteor@1.4.3.2`
 - Merge #46 - Better bots user-agent catching - thanks to @RickvdP
 - Codebase enhancements
 - Dependencies update
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants