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

Signed-off-by: loicbersier <loic.bersier1@gmail.com>
merge-requests/5/merge
loicbersier 4 years ago
parent 101d7b18a4
commit c7e1ba0021

@ -39,6 +39,8 @@ class screenshotCommand extends Command {
// 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()@:%_\+.~#?&//=]*)/);
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
await captureWebsite.file(args.url, `${os.tmpdir()}/${message.id}.jpg`, {
type: 'jpeg',

Loading…
Cancel
Save