Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

redirect to container #621

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
Contributor 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, baseUrl, baseUrl,
null, null, '', null)
// p.loadBuf(xhr.responseText)
try {
Expand Down
2 changes: 1 addition & 1 deletion src/update-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,7 @@ flagAuthorizationMetadata (kb?: IndexedFormula) {
}
} else {
control.reloading = false
if ((response as Response).status === 0) {
if (!response || (response as Response).status === 0) { // alain
// console.log('Network error refreshing the data. Retrying in ' +
// retryTimeout / 1000)
control.reloading = true
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);
});
}) */
})
Loading