1 | const https = require('https')
|
2 | const { URL } = require('url')
|
3 | module.exports = (urlString) => {
|
4 | const { host, port, pathname } = new URL(urlString)
|
5 | return new Promise((resolve, reject) => {
|
6 | const options = {
|
7 | host,
|
8 | port,
|
9 | path: pathname,
|
10 | method: 'HEAD'
|
11 | }
|
12 | const req = https.request(options, (res) => {
|
13 | resolve(res.headers)
|
14 | })
|
15 | req.end()
|
16 | })
|
17 | }
|