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

Commit

Permalink
fix: scrape Url error close #136
Browse files Browse the repository at this point in the history
  • Loading branch information
joolfe committed Aug 14, 2021
1 parent 47b97c8 commit dda9168
Show file tree
Hide file tree
Showing 6 changed files with 435 additions and 163 deletions.
5 changes: 4 additions & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,10 @@ function scrapeURL (url) {
return { valid: false }
}
const rawUrl = (typeof url === 'string' || url instanceof String) ? url : url.raw
const objUrl = new URL(rawUrl)
// Fix for issue #136 if replace vars are not used then new URL throw an error
// when using variables before the schema
const fixedUrl = (rawUrl.startsWith('{{')) ? 'http://' + rawUrl : rawUrl
const objUrl = new URL(fixedUrl)
return {
raw: rawUrl,
path: decodeURIComponent(objUrl.pathname).slice(1).split('/'),
Expand Down
Loading

0 comments on commit dda9168

Please sign in to comment.