Skip to content

Commit 572e970

Browse files
committed
Use http.get or https.get
1 parent 347f8fc commit 572e970

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lib/content.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
'use strict'
22

3-
const { get } = require('http')
3+
const http = require('http')
4+
const https = require('https')
5+
const { URL } = require('url')
46

57
const { render } = require('mustache')
68

@@ -21,6 +23,8 @@ const getIndexContent = (options, callback) => {
2123
const getIndexTemplate = (options, callback) => {
2224
try {
2325
const url = `${options.root}/${templateName}`
26+
const isHttps = new URL(url).protocol === 'https:'
27+
const get = isHttps ? https.get : http.get
2428
get(url, resp => {
2529
let data = ''
2630
resp.on('data', chunk => { data += chunk })

0 commit comments

Comments
 (0)