Merge pull request #36 from o-development/fix/content-type-param

Fix: supports any kind of text/turtle response
main
jaxoncreed 1 year ago committed by GitHub
commit ad4ef1001f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 2
      packages/solid/src/requester/requests/readResource.ts
  2. 18
      packages/solid/test/Integration.test.ts

@ -124,7 +124,7 @@ export async function readResource(
);
}
if (contentType === "text/turtle") {
if (contentType.startsWith("text/turtle")) {
// Parse Turtle
const rawTurtle = await response.text();
if (options?.dataset) {

@ -385,6 +385,24 @@ describe("Integration", () => {
);
});
it("Parses Turtle even when the content type contains parameters", async () => {
fetchMock.mockResolvedValueOnce(
new Response(SPIDER_MAN_TTL, {
status: 200,
headers: new Headers({ "content-type": "text/turtle;charset=utf-8" }),
}),
);
const resource = solidLdoDataset.getResource(SAMPLE_DATA_URI);
const result = await testRequestLoads(() => resource.read(), resource, {
isLoading: true,
isReading: true,
isDoingInitialFetch: true,
});
expect(result.isError).toBe(false);
if (result.isError) return;
expect(result.type).toBe("dataReadSuccess");
});
it("Returns an UnexpectedResourceError if an unknown error is triggered", async () => {
fetchMock.mockRejectedValueOnce(new Error("Something happened."));
const resource = solidLdoDataset.getResource(SAMPLE2_DATA_URI);

Loading…
Cancel
Save