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

Commit

Permalink
fix: check the url can be undefined Close #224
Browse files Browse the repository at this point in the history
  • Loading branch information
joolfe committed Sep 24, 2022
1 parent 8799631 commit cb6e53b
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ function calculateDomains (protocol, hosts, port) {
*/
function scrapeURL (url) {
// Avoid parse empty url request
if (url === '' || url.raw === '') {
if (url === undefined || url === '' || url.raw === '') {
return { valid: false }
}
const rawUrl = (typeof url === 'string' || url instanceof String) ? url : url.raw
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "postman-to-openapi",
"version": "2.7.0",
"version": "2.7.1",
"description": "Convert postman collection to OpenAPI spec",
"main": "lib/index.js",
"types": "types/index.d.ts",
Expand Down
8 changes: 8 additions & 0 deletions test/resources/input/v2/PostmantoOpenAPI.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,14 @@
"description": "Just an example of text raw body"
},
"response": []
},
{
"name": "No url request",
"request": {
"method": "GET",
"header": []
},
"response": []
}
],
"event": [
Expand Down
8 changes: 8 additions & 0 deletions test/resources/input/v21/PostmantoOpenAPI.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,14 @@
"description": "Just an example of text raw body"
},
"response": []
},
{
"name": "No url request",
"request": {
"method": "GET",
"header": []
},
"response": []
}
],
"event": [
Expand Down

0 comments on commit cb6e53b

Please sign in to comment.