Skip to content

Commit

Permalink
/.jref is not a JRef file
Browse files Browse the repository at this point in the history
  • Loading branch information
jdesrosiers committed Aug 7, 2024
1 parent 8d8b799 commit 9df7fb7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/media-types/jref-media-type-plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const jrefMediaTypePlugin = {
anchorLocation: anchorLocation
};
},
fileMatcher: (path) => path.endsWith(".jref")
fileMatcher: (path) => /[^/]\.jref$/.test(path)
};

const anchorLocation = (fragment) => decodeURI(fragment || "");
17 changes: 17 additions & 0 deletions lib/uri-schemes/file-scheme-plugin.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,23 @@ foo: 42
}
});

it("/.jref is not a JRef file", async () => {
const path = `${fixtureDirectory}/.jref`;
const jref = `
foo: 42
`;

await writeFile(fileURLToPath(`${testUri}/${path}`), jref);

try {
await get(path);
expect.fail("Expected RetrievalError => UnknownMediaTypeError");
} catch (error: unknown) {
expect(error).to.be.instanceof(RetrievalError);
expect((error as RetrievalError).cause.name).to.equal("UnknownMediaTypeError");
}
});

describe("http context", () => {
let browser: Browser;

Expand Down

0 comments on commit 9df7fb7

Please sign in to comment.