Skip to content

Commit

Permalink
feat: fix the bug of pr GoogleChrome#9170
Browse files Browse the repository at this point in the history
  • Loading branch information
朱坤坤 committed Jul 31, 2019
1 parent 97ec8d6 commit b22bce2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion lighthouse-cli/bin.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,12 @@ async function begin() {
// the conversion here, but long term either the CLI flag or the setting should have
// a different name.
// @ts-ignore
const extraCookiesStr = /** @type {string} */ (cliFlags.extraCookies);
let extraCookiesStr = /** @type {string} */ (cliFlags.extraCookies);
// If not a JSON object, assume it's a path to a JSON file.
if (extraCookiesStr.substr(0, 1) !== '{') {
extraCookiesStr = fs.readFileSync(extraCookiesStr, 'utf-8');
}

cliFlags.extraCookies = JSON.parse(extraCookiesStr);
if (!Array.isArray(cliFlags.extraCookies)) {
throw new Error('extraCookies parameter must be a valid JSON array');
Expand Down
2 changes: 1 addition & 1 deletion lighthouse-core/gather/gather-runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ class GatherRunner {
return;
}
extraCookies.forEach(cookie => {
if (!cookie.url || !cookie.domain) {
if (!cookie.url && !cookie.domain) {
// Default cookie URL to to current URL, if neither domain nor url is specified
cookie.url = passContext.url;
}
Expand Down

0 comments on commit b22bce2

Please sign in to comment.