diff --git a/lib/dereference.js b/lib/dereference.js index f257d838..9bd67644 100644 --- a/lib/dereference.js +++ b/lib/dereference.js @@ -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); }