From c2937a4ee074c0b429fe5ad77187eff2f0242a14 Mon Sep 17 00:00:00 2001 From: Carlos Rivera Date: Fri, 5 Mar 2021 15:33:55 -0600 Subject: [PATCH] improved coverage --- .jest.json | 2 +- package.json | 2 +- src/bundler.ts | 14 +++++--------- src/index.ts | 2 +- tests/index.test.ts | 2 +- 5 files changed, 9 insertions(+), 13 deletions(-) diff --git a/.jest.json b/.jest.json index bffd1d8..a344764 100644 --- a/.jest.json +++ b/.jest.json @@ -1,6 +1,6 @@ { "transform": { - "^.+\\.(t|j)sx?$": "ts-jest" + "^.+\\.(t)sx?$": "ts-jest" }, "testRegex": "(/tests/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$", "moduleFileExtensions": ["ts", "tsx", "js", "jsx", "json", "node"], diff --git a/package.json b/package.json index 2b5ddca..045007b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@synx-ai/oas3-mdx", - "version": "0.3.9", + "version": "0.3.10", "description": "Convert OpenAPI spec to Markdown files.", "main": "dist/index.js", "types": "dist/index.d.ts", diff --git a/src/bundler.ts b/src/bundler.ts index 042a52a..6a9fafe 100644 --- a/src/bundler.ts +++ b/src/bundler.ts @@ -1,4 +1,4 @@ -"use_strict"; +"use strict"; /** * This file loads, bundles and validates an OpenAPI spec. @@ -48,14 +48,10 @@ const handleHTTPResponse = (url, res, resolve, reject) => { */ const getContentFromURL = (url: string) => { return new Promise((resolve, reject) => { - if (url.startsWith("http:")) { - http - .get(url, (res) => { - handleHTTPResponse(url, res, resolve, reject); - }) - .on("error", reject); - } else if (url.startsWith("https:")) { - https + if (url.startsWith("http")) { + let protocol = url.startsWith("https:") ? https : http; + + protocol .get(url, (res) => { handleHTTPResponse(url, res, resolve, reject); }) diff --git a/src/index.ts b/src/index.ts index 44262f8..cc692f0 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,4 +1,4 @@ -"use_strict"; +"use strict"; import * as fs from "fs"; import * as path from "path"; diff --git a/tests/index.test.ts b/tests/index.test.ts index 6cb2b29..7cc6cb6 100644 --- a/tests/index.test.ts +++ b/tests/index.test.ts @@ -9,7 +9,7 @@ const templatesThatExists = "./example/templates/mdx"; const templatesThatNotExists = "./example/templates/jsx"; const urlThatExists = "https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/examples/v3.0/petstore.yaml"; -const urlThatNotExists = "https://petstore3.synx.io/api/v3/openapi.json"; +const urlThatNotExists = "https://github.com/synx-ai/oas3-mdx/blob/master/404"; describe("convert()", () => {