From 6e9a3bd8ac32dc9adcb5bb8fe445b4c5a447671b Mon Sep 17 00:00:00 2001 From: bourgeoa Date: Fri, 5 May 2023 13:07:26 +0200 Subject: [PATCH 1/5] redirect to container --- src/fetcher.ts | 6 +++++- tests/unit/fetcher-test.js | 22 +++++++++++++++++++++- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/src/fetcher.ts b/src/fetcher.ts index cb449c11c..f002c5a17 100644 --- a/src/fetcher.ts +++ b/src/fetcher.ts @@ -601,7 +601,11 @@ class N3Handler extends Handler { ): ExtendedResponse | Promise { // 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 + '/' + let p = N3Parser(kb, kb, options.original.value, baseUrl, null, null, '', null) // p.loadBuf(xhr.responseText) try { diff --git a/tests/unit/fetcher-test.js b/tests/unit/fetcher-test.js index a949bd3c1..de74b05ee 100644 --- a/tests/unit/fetcher-test.js +++ b/tests/unit/fetcher-test.js @@ -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); + }); }) }) From cf2536ab79a9bf29b11e8db1ee53e3a9753b1ac4 Mon Sep 17 00:00:00 2001 From: bourgeoa Date: Fri, 5 May 2023 13:53:58 +0200 Subject: [PATCH 2/5] remove 301 test --- tests/unit/fetcher-test.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/unit/fetcher-test.js b/tests/unit/fetcher-test.js index de74b05ee..1827bc87c 100644 --- a/tests/unit/fetcher-test.js +++ b/tests/unit/fetcher-test.js @@ -566,7 +566,7 @@ describe('Fetcher', () => { }) }) - describe('301 redirect', () => { + /* describe('301 redirect', () => { let fetcher beforeEach(() => { @@ -588,5 +588,5 @@ describe('Fetcher', () => { ); expect(contains.length).to.equal(0); }); - }) + }) */ }) From 4ffc8f35e5163e340d4330d9cc3df9ce822733e8 Mon Sep 17 00:00:00 2001 From: Alain Bourgeois Date: Thu, 18 May 2023 19:41:11 +0200 Subject: [PATCH 3/5] 301 baseUrl --- src/fetcher.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fetcher.ts b/src/fetcher.ts index f002c5a17..c442332ec 100644 --- a/src/fetcher.ts +++ b/src/fetcher.ts @@ -605,7 +605,7 @@ class N3Handler extends Handler { const isContainer = kb.any(options.original, null, ns.ldp('Container')) console.log('@@ isContainer ' + isContainer) if (isContainer && !baseUrl.endsWith('/')) baseUrl = baseUrl + '/' - let p = N3Parser(kb, kb, options.original.value, baseUrl, + let p = N3Parser(kb, kb, baseUrl, baseUrl, null, null, '', null) // p.loadBuf(xhr.responseText) try { From bddbaee4d12f3784380616230592b1bec64e5a1e Mon Sep 17 00:00:00 2001 From: bourgeoa Date: Thu, 25 May 2023 10:37:44 +0200 Subject: [PATCH 4/5] 301 issue cleaning --- src/fetcher.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fetcher.ts b/src/fetcher.ts index c442332ec..6fb438e9a 100644 --- a/src/fetcher.ts +++ b/src/fetcher.ts @@ -603,7 +603,7 @@ class N3Handler extends Handler { let kb = fetcher.store let baseUrl = options.original.value const isContainer = kb.any(options.original, null, ns.ldp('Container')) - console.log('@@ isContainer ' + isContainer) + // console.log('@@ isContainer ' + isContainer) if (isContainer && !baseUrl.endsWith('/')) baseUrl = baseUrl + '/' let p = N3Parser(kb, kb, baseUrl, baseUrl, null, null, '', null) From 0a0b0c998ed24f44de3700918adf15aae5ff4735 Mon Sep 17 00:00:00 2001 From: bourgeoa Date: Sun, 26 Nov 2023 18:10:45 +0100 Subject: [PATCH 5/5] !response --- src/update-manager.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/update-manager.ts b/src/update-manager.ts index 4478c7b6a..2335478c7 100644 --- a/src/update-manager.ts +++ b/src/update-manager.ts @@ -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