Skip to content
This repository has been archived by the owner on Mar 7, 2021. It is now read-only.

Commit

Permalink
Merge pull request #400 from robinparisi/master
Browse files Browse the repository at this point in the history
Fix wrong meta robots tag attribute
  • Loading branch information
fredrikekelund authored Sep 29, 2017
2 parents 9c70222 + 6fad8c8 commit 1cb0492
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/crawler.js
Original file line number Diff line number Diff line change
Expand Up @@ -903,7 +903,7 @@ Crawler.prototype.discoverResources = function(resourceText) {
}

if (crawler.respectRobotsTxt && /<meta(?:\s[^>]*)?\sname\s*=\s*["']?robots["']?[^>]*>/i.test(resourceText)) {
var robotsValue = /<meta(?:\s[^>]*)?\svalue\s*=\s*["']?([\w\s,]+)["']?[^>]*>/i.exec(resourceText.toLowerCase());
var robotsValue = /<meta(?:\s[^>]*)?\scontent\s*=\s*["']?([\w\s,]+)["']?[^>]*>/i.exec(resourceText.toLowerCase());

if (Array.isArray(robotsValue) && /nofollow/i.test(robotsValue[1])) {
return [];
Expand Down
4 changes: 2 additions & 2 deletions test/discovery.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,10 +203,10 @@ describe("Crawler link discovery", function() {

it("should respect nofollow values in robots meta tags", function() {

discover("<meta name='robots' value='nofollow'><a href='/stage2'>Don't follow me!</a>")
discover("<meta name='robots' content='nofollow'><a href='/stage2'>Don't follow me!</a>")
.should.eql([]);

discover("<meta name='robots' value='nofollow, noindex'><a href='/stage2'>Don't follow me!</a>")
discover("<meta name='robots' content='nofollow, noindex'><a href='/stage2'>Don't follow me!</a>")
.should.eql([]);
});
});
2 changes: 1 addition & 1 deletion test/lib/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ module.exports = {
},

"/nofollow": function(write) {
write(200, "<meta name='robots' value='nofollow'><a href='/stage7'>Don't go here!</a>");
write(200, "<meta name='robots' content='nofollow'><a href='/stage7'>Don't go here!</a>");
},

"/cookie": function(write) {
Expand Down

0 comments on commit 1cb0492

Please sign in to comment.