Skip to content

Commit e68483d

Browse files
authored
Merge pull request #1153 from shockey/bug/1152-startswith-usage
Refactor `startsWith` usage for IE11 compatibility
2 parents 38596d9 + c2b3214 commit e68483d

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/helpers.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import isObject from 'lodash/isObject'
2+
import startsWith from 'lodash/startsWith'
23

34
const toLower = str => String.prototype.toLowerCase.call(str)
45
const escapeString = (str) => {
@@ -12,7 +13,7 @@ export function isOAS3(spec) {
1213
return false
1314
}
1415

15-
return oasVersion.startsWith('3.0.0')
16+
return startsWith(oasVersion, '3')
1617
}
1718

1819
export function isSwagger2(spec) {
@@ -21,7 +22,7 @@ export function isSwagger2(spec) {
2122
return false
2223
}
2324

24-
return swaggerVersion.startsWith('2')
25+
return startsWith(swaggerVersion, '2')
2526
}
2627

2728
// Strategy for determining operationId

src/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import cloneDeep from 'lodash/cloneDeep'
22
import assign from 'lodash/assign'
3+
import startsWith from 'lodash/startsWith'
34
import Url from 'url'
45
import Http, {makeHttp, serializeRes, serializeHeaders} from './http'
56
import Resolver, {clearCache} from './resolver'
@@ -82,7 +83,7 @@ Swagger.prototype.applyDefaults = function () {
8283
const spec = this.spec
8384
const specUrl = this.url
8485
// TODO: OAS3: support servers here
85-
if (specUrl && specUrl.startsWith('http')) {
86+
if (specUrl && startsWith(specUrl, 'http')) {
8687
const parsed = Url.parse(specUrl)
8788
if (!spec.host) {
8889
spec.host = parsed.host

0 commit comments

Comments
 (0)