lib/grover/js/processor.cjs in grover-1.1.8 vs lib/grover/js/processor.cjs in grover-1.1.9
- old
+ new
@@ -24,11 +24,11 @@
const fs = require('fs');
const os = require('os');
const path = require('path');
-const _processPage = (async (convertAction, urlOrHtml, options) => {
+const _processPage = (async (convertAction, uriOrHtml, options) => {
let browser, page, errors = [], tmpDir, wsConnection = false;
try {
// Configure puppeteer debugging options
const debug = options.debug; delete options.debug;
@@ -171,14 +171,16 @@
errors.push(request);
});
}
const waitUntil = options.waitUntil; delete options.waitUntil;
- if (urlOrHtml.match(/^http/i)) {
+ const allowFileUri = options.allowFileUri; delete options.allowFileUri;
+ const uriRegex = allowFileUri ? /^(https?|file):\/\//i : /^https?:\/\//i;
+ if (uriOrHtml.match(uriRegex)) {
// Request is for a URL, so request it
requestOptions.waitUntil = waitUntil || 'networkidle2';
- await page.goto(urlOrHtml, requestOptions);
+ await page.goto(uriOrHtml, requestOptions);
} else {
// Request is some HTML content. Use request interception to assign the body
requestOptions.waitUntil = waitUntil || 'networkidle0';
await page.setRequestInterception(true);
let htmlIntercepted = false;
@@ -186,10 +188,10 @@
// We only want to intercept the first request - ie our HTML
if (htmlIntercepted)
request.continue();
else {
htmlIntercepted = true
- request.respond({ body: urlOrHtml === '' ? ' ' : urlOrHtml });
+ request.respond({ body: uriOrHtml === '' ? ' ' : uriOrHtml });
}
});
const displayUrl = options.displayUrl; delete options.displayUrl;
await page.goto(displayUrl || 'http://example.com', requestOptions);
}