redirect to external URLs - closes #490

This commit is contained in:
Rich Harris
2018-10-27 12:14:28 -04:00
parent ab52aabd1d
commit e69cb3639a
5 changed files with 66 additions and 8 deletions

View File

@@ -50,6 +50,20 @@ export class AppRunner {
}
});
await this.page.setRequestInterception(true);
this.page.on('request', interceptedRequest => {
if (/example\.com/.test(interceptedRequest.url())) {
interceptedRequest.respond({
status: 200,
contentType: 'text/html',
body: `<h1>external</h1>`
});
} else {
interceptedRequest.continue();
}
});
return {
page: this.page,
base: `http://localhost:${this.port}`,