Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/fetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,11 @@ class N3Handler extends Handler {
): ExtendedResponse | Promise<FetchError> {
// Parse the text of this N3 file
let kb = fetcher.store
let p = N3Parser(kb, kb, options.original.value, options.original.value,
let baseUrl = options.original.value
const isContainer = kb.any(options.original, null, ns.ldp('Container'))
console.log('@@ isContainer ' + isContainer)
if (isContainer && !baseUrl.endsWith('/')) baseUrl = baseUrl + '/'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is the proper way to solve this problem, what if the redirect goes to a different path altogether (for whatever reason)? We should be reading from the response.url instead. And if we don't consider redirecting to a completely different resource a valid situation, throw an error rather than keep going with potentially wrong data.

Copy link
Member Author

@bourgeoa bourgeoa May 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well I was on your line but that was conflicting with the point raised by @timbl that there was (may have been) a proxy related reason not to use the response.url

let p = N3Parser(kb, kb, options.original.value, baseUrl,
null, null, '', null)
// p.loadBuf(xhr.responseText)
try {
Expand Down
24 changes: 22 additions & 2 deletions tests/unit/fetcher-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,27 @@ describe('Fetcher', () => {
})
})

describe('createContainer', () => {
/* describe('301 redirect', () => {
let fetcher

beforeEach(() => {
fetcher = new Fetcher(rdf.graph())
})

afterEach(() => {
nock.cleanAll()
})

// it.skip('should invoke webOperation with the right options', () => {})
})
it("should contain nothing", async () => {
const store = rdf.graph();
const fetcher = new Fetcher(store);
await fetcher.load("https://bourgeoa.solidcommunity.net/chats");
const contains = store.statementsMatching(
rdf.sym("https://bourgeoa.solidcommunity.net/chats"),
rdf.sym("http://www.w3.org/ns/ldp#contains")
);
expect(contains.length).to.equal(0);
});
}) */
})