Skip to content

Commit

Permalink
Spiderable.userAgentRegExps can now be modified to change what user a…
Browse files Browse the repository at this point in the history
…gents are

treated as spiders by the spiderable package.
  • Loading branch information
glasser committed Apr 9, 2013
1 parent 73afb30 commit 308395d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
3 changes: 3 additions & 0 deletions History.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@

## vNEXT

* `Spiderable.userAgentRegExps` can now be modified to change what user agents
are treated as spiders by the `spiderable` package.

* Return the inserted documented ID from LocalCollection.insert. #908

* Prevent observe callbacks from affecting the arguments to identical observes. #855
Expand Down
8 changes: 5 additions & 3 deletions packages/spiderable/spiderable.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,20 @@ var querystring = Npm.require('querystring');
var urlParser = Npm.require('url');
var app = __meteor_bootstrap__.app;

Spiderable = {};

// list of bot user agents that we want to serve statically, but do
// not obey the _escaped_fragment_ protocol. The page is served
// statically to any client whos user agent matches any of these
// regexps. (possibly make this list configurable by user).
var AGENTS = [/^facebookexternalhit/i, /^linkedinbot/i];
// regexps. Users may modify this array.
Spiderable.userAgentRegExps = [/^facebookexternalhit/i, /^linkedinbot/i];

// how long to let phantomjs run before we kill it
var REQUEST_TIMEOUT = 15*1000;

app.use(function (req, res, next) {
if (/\?.*_escaped_fragment_=/.test(req.url) ||
_.any(AGENTS, function (re) {
_.any(Spiderable.userAgentRegExps, function (re) {
return re.test(req.headers['user-agent']); })) {

// reassembling url without escaped fragment if exists
Expand Down

0 comments on commit 308395d

Please sign in to comment.