Add "http://" automatically if its not included

Signed-off-by: loicbersier <loic.bersier1@gmail.com>
This commit is contained in:
loicbersier 2020-05-02 02:11:02 +02:00
parent 101d7b18a4
commit c7e1ba0021

View file

@ -39,6 +39,8 @@ class screenshotCommand extends Command {
// eslint-disable-next-line no-useless-escape // eslint-disable-next-line no-useless-escape
let urlregex = new RegExp(/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)/); let urlregex = new RegExp(/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)/);
if (!args.url.includes('http')) args.url = 'http://' + args.url;
console.log(args.url);
if (args.url.match(urlregex)) { // Only allow link with http/https if (args.url.match(urlregex)) { // Only allow link with http/https
await captureWebsite.file(args.url, `${os.tmpdir()}/${message.id}.jpg`, { await captureWebsite.file(args.url, `${os.tmpdir()}/${message.id}.jpg`, {
type: 'jpeg', type: 'jpeg',