Skip to content
This repository was archived by the owner on Dec 27, 2024. It is now read-only.

Commit dda9168

Browse files
committed
fix: scrape Url error close #136
1 parent 47b97c8 commit dda9168

6 files changed

Lines changed: 435 additions & 163 deletions

File tree

lib/index.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,10 @@ function scrapeURL (url) {
358358
return { valid: false }
359359
}
360360
const rawUrl = (typeof url === 'string' || url instanceof String) ? url : url.raw
361-
const objUrl = new URL(rawUrl)
361+
// Fix for issue #136 if replace vars are not used then new URL throw an error
362+
// when using variables before the schema
363+
const fixedUrl = (rawUrl.startsWith('{{')) ? 'http://' + rawUrl : rawUrl
364+
const objUrl = new URL(fixedUrl)
362365
return {
363366
raw: rawUrl,
364367
path: decodeURIComponent(objUrl.pathname).slice(1).split('/'),

0 commit comments

Comments
 (0)