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

core: add node 6 support to (patched) robots-parser #4851

Merged
merged 1 commit into from
Mar 23, 2018

Conversation

paulirish
Copy link
Member

@paulirish paulirish commented Mar 22, 2018

Our new patch leaves out node 6 out in cold:
https://travis-ci.org/GoogleChrome/lighthouse/jobs/357025749#L634

node 6.13 has require('url').URL but its a month old and no other node 6 has it.
so we'll add this backwards-compat support for the rest of node 6's out there.

This PR is for branch2.x only.

Konrad has an upcoming PR to roll latest robots-parser (which will now be node 7+ only).

Audience-wise: this patch only matters for our Node 6 (>6.0.0 and <6.13.0) CLI users

brendankenny
brendankenny previously approved these changes Mar 22, 2018
Copy link
Member

@brendankenny brendankenny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@@ -30,7 +40,7 @@ patch-package
var rules = this._rules[userAgent] || this._rules['*'] || [];

- return isPathAllowed(parsedUrl.path, rules);
+ return isPathAllowed(parsedUrl.pathname + parsedUrl.search, rules);
+ return isPathAllowed(getPath(parsedUrl), rules);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/getPath/getUrlPath/

@paulirish
Copy link
Member Author

PTAL

I'm committed to making this work. Even if it hates me. 👿

This fixes:

  1. node 6.0 - 6.12 support
  2. gracefully handling invalid URLs discovered by robots-parser

Konrad's forthcoming PR will also handle the latter, whereas current master fails on it. Honestly, not a huge deal because the invalid URLs would have to be either A) the robots.txt resolved URL or B) the main resource URL. Both of these will always be valid so it's not a huge deal. Was just something the robots-parser tests caught.

@paulirish paulirish merged commit 8221821 into branch2.x Mar 23, 2018
@paulirish paulirish deleted the robotsnode6fix branch March 23, 2018 22:12
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.

4 participants