Skip to content

Commit 235ab56

Browse files
committed
#3 Adding appropriate error management
1 parent 856b5ee commit 235ab56

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/utils.js

+11-4
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,17 @@ export function isRefArray(field, schema) {
2424
}
2525

2626
function fetchSchema(ref, schema) {
27-
let relevantSchema = ref.split("/");
28-
return relevantSchema
29-
.filter(ref => ref !== "#")
30-
.reduce((schema, field) => schema[field], schema);
27+
if (ref.startsWith("#/")) {
28+
ref.substr(2).split("/");
29+
return ref
30+
.substr(2)
31+
.split("/")
32+
.reduce((schema, field) => schema[field], schema);
33+
} else {
34+
toError(
35+
"Only local references supported at this point use json-schema-deref"
36+
);
37+
}
3138
}
3239

3340
export function extractRefSchema(field, schema) {

0 commit comments

Comments
 (0)