Skip to content

Commit e76ba2f

Browse files
lvzhenboatinux
andauthored
feat: detect IP and localhost sites and remove mandatory https access (#87)
* feat: add vitepress detection * chore: update vitepress logo * Update vitepress.svg * feat: detect IP and localhost sites and remove mandatory https access Co-authored-by: Sébastien Chopin <[email protected]>
1 parent 0fd1e22 commit e76ba2f

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/index.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,15 @@ async function analyze (originalUrl, options = {}) {
5050
browser = null
5151
})
5252
}
53-
// Force https
54-
originalUrl = 'https://' + url.hostname + url.pathname
55-
const domain = tldParser(url.origin).domain
53+
54+
originalUrl = url.protocol + '//' + url.hostname + ':' + url.port + url.pathname
55+
let domain
56+
if (url.hostname === 'localhost' || url.hostname.match(/^((2((5[0-5])|([0-4]\d)))|([0-1]?\d{1,2}))(\.((2((5[0-5])|([0-4]\d)))|([0-1]?\d{1,2}))){3}$/)) {
57+
domain = url.hostname;
58+
} else {
59+
domain = tldParser(url.origin).domain
60+
}
61+
5662
const page = await browser.newPage()
5763
const infos = {
5864
url: originalUrl,

0 commit comments

Comments
 (0)