fix: restore node 12 support
This commit is contained in:
parent
3705d1fea9
commit
a37ff69692
1 changed files with 5 additions and 3 deletions
|
|
@ -68,9 +68,11 @@ class MessageMedia {
|
||||||
const reqOptions = Object.assign({ headers: { accept: 'image/* video/* text/* audio/*' } }, options);
|
const reqOptions = Object.assign({ headers: { accept: 'image/* video/* text/* audio/*' } }, options);
|
||||||
const response = await fetch(url, reqOptions);
|
const response = await fetch(url, reqOptions);
|
||||||
const mime = response.headers.get('Content-Type');
|
const mime = response.headers.get('Content-Type');
|
||||||
const name = response.headers.get('Content-Disposition')?.match(/((?<=filename=")(.*)(?="))/);
|
|
||||||
let data = '';
|
|
||||||
|
|
||||||
|
const contentDisposition = response.headers.get('Content-Disposition');
|
||||||
|
const name = contentDisposition ? contentDisposition.match(/((?<=filename=")(.*)(?="))/) : null;
|
||||||
|
|
||||||
|
let data = '';
|
||||||
if (response.buffer) {
|
if (response.buffer) {
|
||||||
data = (await response.buffer()).toString('base64');
|
data = (await response.buffer()).toString('base64');
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -88,7 +90,7 @@ class MessageMedia {
|
||||||
? (await options.client.pupPage.evaluate(fetchData, url, options.reqOptions))
|
? (await options.client.pupPage.evaluate(fetchData, url, options.reqOptions))
|
||||||
: (await fetchData(url, options.reqOptions));
|
: (await fetchData(url, options.reqOptions));
|
||||||
|
|
||||||
const filename = options.filename ??
|
const filename = options.filename ||
|
||||||
(res.name ? res.name[0] : (pUrl.pathname.split('/').pop() || 'file'));
|
(res.name ? res.name[0] : (pUrl.pathname.split('/').pop() || 'file'));
|
||||||
|
|
||||||
if (!mimetype)
|
if (!mimetype)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue