From e0113a515eb918c18e7f398cdaa113661fa47747 Mon Sep 17 00:00:00 2001 From: Kyle Shockey Date: Fri, 13 Oct 2017 18:50:07 -0700 Subject: [PATCH] Use lodash startsWith instead of ES6 builtin method --- src/helpers.js | 5 +++-- src/index.js | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/helpers.js b/src/helpers.js index 0f92a9173..9e131eb74 100755 --- a/src/helpers.js +++ b/src/helpers.js @@ -1,4 +1,5 @@ import isObject from 'lodash/isObject' +import startsWith from 'lodash/startsWith' const toLower = str => String.prototype.toLowerCase.call(str) const escapeString = (str) => { @@ -12,7 +13,7 @@ export function isOAS3(spec) { return false } - return oasVersion.startsWith('3.0.0') + return startsWith(oasVersion, '3') } export function isSwagger2(spec) { @@ -21,7 +22,7 @@ export function isSwagger2(spec) { return false } - return swaggerVersion.startsWith('2') + return startsWith(swaggerVersion, '2') } // Strategy for determining operationId diff --git a/src/index.js b/src/index.js index 90315115d..cfcc9bff4 100644 --- a/src/index.js +++ b/src/index.js @@ -1,5 +1,6 @@ import cloneDeep from 'lodash/cloneDeep' import assign from 'lodash/assign' +import startsWith from 'lodash/startsWith' import Url from 'url' import Http, {makeHttp, serializeRes, serializeHeaders} from './http' import Resolver, {clearCache} from './resolver' @@ -82,7 +83,7 @@ Swagger.prototype.applyDefaults = function () { const spec = this.spec const specUrl = this.url // TODO: OAS3: support servers here - if (specUrl && specUrl.startsWith('http')) { + if (specUrl && startsWith(specUrl, 'http')) { const parsed = Url.parse(specUrl) if (!spec.host) { spec.host = parsed.host