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(audit-mode): do not require a URL #5495

Merged
merged 5 commits into from
Jun 13, 2018

Conversation

patrickhulce
Copy link
Collaborator

realized in #5493 that requiring a URL in audit mode is silly, this removes that requirement

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.

nice! Mostly some drive by cleanup requests

@@ -138,7 +138,9 @@ function getFlags(manualArgv) {
.check(/** @param {!LH.Flags} argv */ (argv) => {
// Make sure lighthouse has been passed a url, or at least one of --list-all-audits
// or --list-trace-categories. If not, stop the program and ask for a url
Copy link
Member

Choose a reason for hiding this comment

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

update comment too

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

if (!requestedUrl) {
throw new Error('Cannot run audit mode on empty URL');
}
if (opts.url && opts.url !== requestedUrl) {
Copy link
Member

Choose a reason for hiding this comment

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

might throw a wrench in the type checking works, but opts.url should now be optional in the function params?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

} else {
// save the requestedUrl provided by the user
Copy link
Member

Choose a reason for hiding this comment

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

we can ditch this comment now since we don't actually save it anymore (can also just drop it and use opts.url in its place)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

log.warn('Lighthouse', 'Performance stats might be skewed redirecting to HTTPS.');
}

// canonicalize URL with any trailing slashes neccessary
Copy link
Member

Choose a reason for hiding this comment

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

this comment is just weird now. Add an if? Drop the necessary? Something else?

Copy link
Member

Choose a reason for hiding this comment

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

how about .. move this comment to L77 and drop the use of parsedURL and s/parsedURL/requestedUrl/ ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done


let parsedURL;
try {
parsedURL = new URL(opts.url);
Copy link
Member

Choose a reason for hiding this comment

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

rawRequestedUrl

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

N/A

}

// If the URL isn't https and is also not localhost complain to the user.
if (parsedURL.protocol !== 'https:' && parsedURL.hostname !== 'localhost') {
Copy link
Member

Choose a reason for hiding this comment

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

I was gonna say two things...

  1. we could use is-on-https's isSecureRecord method here..
  2. lets merge the strings and just say 'The URL provided should be on HTTPS. Performance stats might be skewed redirecting to HTTPS.'

but tbh..

how about we nuke this check? Our redirects audit already catches perf cost of redirects. and if someone wants to audit a http page, they should be able to.

Copy link
Member

Choose a reason for hiding this comment

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

also, in the future, i'd like to support example.com and just toss https:// in front of it. psi supports this. i think wpt, too.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yeah sg :)

Copy link
Member

Choose a reason for hiding this comment

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

a bigger issue is service workers and how do you notice you aren't getting one because you typed in http, but agree there could be a better flow (we have top level warnings for that kind of thing now)

log.warn('Lighthouse', 'Performance stats might be skewed redirecting to HTTPS.');
}

// canonicalize URL with any trailing slashes neccessary
Copy link
Member

Choose a reason for hiding this comment

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

how about .. move this comment to L77 and drop the use of parsedURL and s/parsedURL/requestedUrl/ ?

Copy link
Member

@paulirish paulirish left a comment

Choose a reason for hiding this comment

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

lgtm

const opts = {url: 'https://example.com', config: generateConfig(settings), driverMock};
try {
await Runner.run(null, opts);
assert.fail('should have thrown');
Copy link
Member

Choose a reason for hiding this comment

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

won't this be caught by the try/catch and so never fail?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yeah but the message won't match, it's the same weird pattern observed elsewhere in the tests :) jest has some much niftier matchers FWIW ;)

Copy link
Member

Choose a reason for hiding this comment

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

oh right. That's confusing but ok :)

@patrickhulce patrickhulce changed the title core(auditMode): do not require a URL core(audit-mode): do not require a URL Jun 13, 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.

LGTM2!

@patrickhulce patrickhulce merged commit deaf607 into master Jun 13, 2018
@patrickhulce patrickhulce deleted the dont_require_url_audit_mode branch June 13, 2018 21:28
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.

None yet

3 participants