Skip to content

Commit 809235e

Browse files
loaders now defaults to fsResolution instead of httpResolution
1 parent 1118c26 commit 809235e

File tree

4 files changed

+14
-12
lines changed

4 files changed

+14
-12
lines changed

src/loaders/internal/Loader.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,12 @@ methods.parseJSON = (str) => {
7070

7171
methods.resolve = (options, uri, { $ref = '' } = {}) => {
7272
const uriToLoad = resolve(uri, $ref)
73-
if (parse(uriToLoad).protocol === 'file:') {
74-
return options.fsResolver.resolve(uriToLoad.split('#')[0])
73+
const protocol = parse(uriToLoad).protocol
74+
if (protocol && protocol.substr(0,4) === 'http') {
75+
return options.httpResolver.resolve(uriToLoad.split('#')[0])
7576
}
7677

77-
return options.httpResolver.resolve(uriToLoad.split('#')[0])
78+
return options.fsResolver.resolve(uriToLoad.split('#')[0])
7879
}
7980

8081

src/loaders/postman/v2.0/Loader.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,11 @@ methods.isParsable = (content) => {
8787
methods.resolve = (options, uri, { $ref = '' } = {}) => {
8888
const uriToLoad = resolve(uri, $ref)
8989
const protocol = parse(uriToLoad).protocol
90-
if (protocol === 'file:' || protocol === 'file') {
91-
return options.fsResolver.resolve(uriToLoad.split('#')[0])
90+
if (protocol && protocol.substr(0,4) === 'http') {
91+
return options.httpResolver.resolve(uriToLoad.split('#')[0])
9292
}
9393

94-
return options.httpResolver.resolve(uriToLoad.split('#')[0])
94+
return options.fsResolver.resolve(uriToLoad.split('#')[0])
9595
}
9696

9797
methods.normalizeRequestItem = (item) => {

src/loaders/swagger/Loader.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,12 @@ methods.traverse = (content, { $ref = '#/' } = {}) => {
122122

123123
methods.resolve = (options, uri, { $ref = '' } = {}) => {
124124
const uriToLoad = resolve(uri, $ref)
125-
if (parse(uriToLoad).protocol === 'file:') {
126-
return options.fsResolver.resolve(uriToLoad.split('#')[0])
125+
const protocol = parse(uriToLoad).protocol
126+
if (protocol && protocol.substr(0,4) === 'http') {
127+
return options.httpResolver.resolve(uriToLoad.split('#')[0])
127128
}
128129

129-
return options.httpResolver.resolve(uriToLoad.split('#')[0])
130+
return options.fsResolver.resolve(uriToLoad.split('#')[0])
130131
}
131132

132133
methods.objectMap = (obj, func) => {

src/loaders/template/v1.0/Loader.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -125,11 +125,11 @@ methods.isParsable = (content) => {
125125
methods.resolve = (options, uri, { $ref = '' } = {}) => {
126126
const uriToLoad = resolve(uri, $ref)
127127
const protocol = parse(uriToLoad).protocol
128-
if (protocol === 'file:' || protocol === 'file' || !protocol) {
129-
return options.fsResolver.resolve(uriToLoad.split('#')[0])
128+
if (protocol && protocol.substr(0,4) === 'http') {
129+
return options.httpResolver.resolve(uriToLoad.split('#')[0])
130130
}
131131

132-
return options.httpResolver.resolve(uriToLoad.split('#')[0])
132+
return options.fsResolver.resolve(uriToLoad.split('#')[0])
133133
}
134134

135135
/**

0 commit comments

Comments
 (0)