Skip to content

Commit 9df7fb7

Browse files
committed
/.jref is not a JRef file
1 parent 8d8b799 commit 9df7fb7

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

lib/media-types/jref-media-type-plugin.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export const jrefMediaTypePlugin = {
99
anchorLocation: anchorLocation
1010
};
1111
},
12-
fileMatcher: (path) => path.endsWith(".jref")
12+
fileMatcher: (path) => /[^/]\.jref$/.test(path)
1313
};
1414

1515
const anchorLocation = (fragment) => decodeURI(fragment || "");

lib/uri-schemes/file-scheme-plugin.spec.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,23 @@ foo: 42
5252
}
5353
});
5454

55+
it("/.jref is not a JRef file", async () => {
56+
const path = `${fixtureDirectory}/.jref`;
57+
const jref = `
58+
foo: 42
59+
`;
60+
61+
await writeFile(fileURLToPath(`${testUri}/${path}`), jref);
62+
63+
try {
64+
await get(path);
65+
expect.fail("Expected RetrievalError => UnknownMediaTypeError");
66+
} catch (error: unknown) {
67+
expect(error).to.be.instanceof(RetrievalError);
68+
expect((error as RetrievalError).cause.name).to.equal("UnknownMediaTypeError");
69+
}
70+
});
71+
5572
describe("http context", () => {
5673
let browser: Browser;
5774

0 commit comments

Comments
 (0)