parent
17960e5d8d
commit
bb1c5215a8
@ -49,7 +49,6 @@
|
|||||||
"devtools-protocol": "0.0.799653",
|
"devtools-protocol": "0.0.799653",
|
||||||
"extract-zip": "^2.0.0",
|
"extract-zip": "^2.0.0",
|
||||||
"https-proxy-agent": "^4.0.0",
|
"https-proxy-agent": "^4.0.0",
|
||||||
"mime": "^2.0.3",
|
|
||||||
"pkg-dir": "^4.2.0",
|
"pkg-dir": "^4.2.0",
|
||||||
"progress": "^2.0.1",
|
"progress": "^2.0.1",
|
||||||
"proxy-from-env": "^1.0.0",
|
"proxy-from-env": "^1.0.0",
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
import { promisify } from 'util';
|
import { promisify } from 'util';
|
||||||
import { EventEmitter } from './EventEmitter.js';
|
import { EventEmitter } from './EventEmitter.js';
|
||||||
import * as mime from 'mime';
|
|
||||||
import {
|
import {
|
||||||
Connection,
|
Connection,
|
||||||
CDPSession,
|
CDPSession,
|
||||||
@ -1623,10 +1622,17 @@ export class Page extends EventEmitter {
|
|||||||
);
|
);
|
||||||
screenshotType = options.type;
|
screenshotType = options.type;
|
||||||
} else if (options.path) {
|
} else if (options.path) {
|
||||||
const mimeType = mime.getType(options.path);
|
const filePath = options.path;
|
||||||
if (mimeType === 'image/png') screenshotType = 'png';
|
const extension = filePath
|
||||||
else if (mimeType === 'image/jpeg') screenshotType = 'jpeg';
|
.slice(filePath.lastIndexOf('.') + 1)
|
||||||
assert(screenshotType, 'Unsupported screenshot mime type: ' + mimeType);
|
.toLowerCase();
|
||||||
|
if (extension === 'png') screenshotType = 'png';
|
||||||
|
else if (extension === 'jpg' || extension === 'jpeg')
|
||||||
|
screenshotType = 'jpeg';
|
||||||
|
assert(
|
||||||
|
screenshotType,
|
||||||
|
`Unsupported screenshot type for extension \`.${extension}\``
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!screenshotType) screenshotType = 'png';
|
if (!screenshotType) screenshotType = 'png';
|
||||||
|
Loading…
Reference in New Issue
Block a user