-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
validates page capture and cancels upload
if the root html capture doesn't return a status code 200, the upload process is canceled
- Loading branch information
Showing
2 changed files
with
23 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
module.exports = class ValidatePlugin { | ||
apply(registerAction) { | ||
registerAction('error', async ({error}) => {console.error(error)}); | ||
registerAction('onResourceError', ({resource, error}) => console.log(`Resource ${resource.url} has error ${error}`)); | ||
registerAction('afterResponse', async ({response}) => { | ||
if (response.statusCode !== 200) { | ||
// Don't capture bad assets. Also cancels the upload phase if the root page has a bad status code. | ||
console.log( `Bad status code ${response.statusCode} , cancelling asset capture` ); | ||
return null; | ||
} else { | ||
return { | ||
body: response.body, | ||
metadata: { | ||
headers: response.headers, | ||
} | ||
}; | ||
} | ||
}); | ||
} | ||
} |