From a9368d439409d0af881e3e9386bae5250965ba4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20=27rysiek=27=20Wo=C5=BAniak?= Date: Wed, 8 Sep 2021 07:33:55 +0000 Subject: [PATCH] gun-ipfs: application/json content-type guessing implemented; plus a relevant test --- __tests__/plugins/gun-ipfs.test.js | 6 ++++++ plugins/gun-ipfs.js | 3 +++ 2 files changed, 9 insertions(+) diff --git a/__tests__/plugins/gun-ipfs.test.js b/__tests__/plugins/gun-ipfs.test.js index d0ee982..dae1163 100644 --- a/__tests__/plugins/gun-ipfs.test.js +++ b/__tests__/plugins/gun-ipfs.test.js @@ -107,6 +107,12 @@ describe("plugin: gun-ipfs", () => { expect(self.log).toHaveBeenCalledWith('gun-ipfs', " +-- guessed contentType : text/javascript") self.log.mockClear() + try { + await self.LibResilientPlugins[0].fetch(self.location.origin + '/test.json') + } catch(e) {} + expect(self.log).toHaveBeenCalledWith('gun-ipfs', " +-- guessed contentType : application/json") + self.log.mockClear() + try { await self.LibResilientPlugins[0].fetch(self.location.origin + '/test.svg') } catch(e) {} diff --git a/plugins/gun-ipfs.js b/plugins/gun-ipfs.js index b0c4ed4..d951f49 100644 --- a/plugins/gun-ipfs.js +++ b/plugins/gun-ipfs.js @@ -201,6 +201,9 @@ if (typeof window === 'undefined') { case 'js': contentType = 'text/javascript'; break; + case 'json': + contentType = 'application/json'; + break; case 'svg': contentType = 'image/svg+xml'; break;