Update WebEmbed.js

This commit is contained in:
John Marlo 2022-04-01 16:41:06 +08:00 committed by GitHub
parent 5953ec764e
commit f8ce147a52
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -11,6 +11,18 @@ class WebEmbed {
this._setup(data);
}
_setup(data) {
/**
* Shorten the link
* @type {?boolean}
*/
this.shorten = data.shorten ?? false;
/**
* Hidden Embed link
* @type {?boolean}
*/
this.hidden = data.hidden ?? false;
/**
* The title of this embed
* @type {?string}
@ -277,12 +289,12 @@ class WebEmbed {
);
}
const fullURL = `${baseURL}${arrayQuery.join('&')}`;
if (shorten) {
if (this.shorten) {
const url = await getShorten(fullURL);
if (!url) console.log('Cannot shorten URL in WebEmbed');
return hidden ? `${hiddenCharter} ${url || fullURL}` : (url || fullURL);
return this.hidden ? `${hiddenCharter} ${url || fullURL}` : (url || fullURL);
} else {
return hidden ? `${hiddenCharter} ${fullURL}` : fullURL;
return this.hidden ? `${hiddenCharter} ${fullURL}` : fullURL;
}
}
}