diff --git a/package-lock.json b/package-lock.json index b276718..eb65b9c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "easy_header", - "version": "1.0.8", + "version": "1.0.9", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index fb9b15d..30c008a 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "displayName": "👊 Power Header 💥", "description": "Automatically (or via command or shortcut) insert (and update) file header text (author comment). Easy configuration and powerful customization to fit any needs!", "publisher": "epivision", - "version": "1.0.8", + "version": "1.0.9", "license": "SEE LICENSE IN LICENSE", "homepage": "https://github.com/EPIVISION/vscode-file-header", "repository": { diff --git a/src/read.ts b/src/read.ts index 54e81df..4890d8f 100644 --- a/src/read.ts +++ b/src/read.ts @@ -28,17 +28,18 @@ async function file(url: URL) { // partially from https://stackoverflow.com/questions/6968448/where-is-body-in-a-nodejs-http-get-response/50244236#50244236 async function remote(url: URL) { - const { get } = await import(url.protocol.slice(0, -1)); + const protocol = url.protocol.slice(0, -1); + const { get } = protocol === 'https' ? await import('https') : await import('http'); return new Promise((resolve, reject) => { get(url, (res) => { - let data = ''; + let data = ''; - // A chunk of data has been received. - res.on('data', (chunk) => { data += chunk; }); + // A chunk of data has been received. + res.on('data', (chunk) => { data += chunk; }); - // The whole response has been received. Print out the result. - res.on('end', () => { resolve(data); }); + // The whole response has been received. Print out the result. + res.on('end', () => { resolve(data); }); }).on('error', (err) => { reject(err); }); }); }