Skip to content

Commit

Permalink
chore: fix lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
darrenyong committed Oct 24, 2023
1 parent 68b649f commit f217276
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/dereference.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,14 @@ function crawl(obj, path, pathFromRoot, parents, processedObjects, dereferencedC
const keyPathFromRoot = Pointer.join(pathFromRoot, key);
const value = obj[key];
// Ensure that there are valid refs. Refs like #components/schemas is invalid
const refSlashSplit = value?.$ref?.split("/");
const refSlashSplit = value?.$ref?.split('/');

// Catches external file refs: /absolute-root/absolute-root.yaml
const refHashSplit = value?.ref?.split("#");
const refHashSplit = value?.ref?.split('#');

// Valid refs split on `/` should have an element with '#' as the last character
// #components/schemas will not return a "validRef"
const validRef = refSlashSplit?.find(ele => ele.slice(-1) === "#")
const validRef = refSlashSplit?.find(ele => ele.slice(-1) === '#');
if (refSlashSplit?.length > 1 && refHashSplit?.length > 1 && !validRef) {
throw new InvalidPointerError(value.$ref, keyPath);
}
Expand Down

0 comments on commit f217276

Please sign in to comment.