From 4ca130134c8addb6cb6ff8994aad8eb63eeaf2bb Mon Sep 17 00:00:00 2001 From: Daniel Date: Tue, 3 Oct 2023 16:17:09 +0200 Subject: [PATCH] Revert "feat!: add NodeData.encodedSource " Signed-off-by: Daniel Kesselberg --- __tests__/dav/dav.spec.ts | 14 -------- __tests__/files/file.spec.ts | 12 ------- __tests__/files/folder.spec.ts | 6 ---- __tests__/files/node.spec.ts | 58 ---------------------------------- __tests__/newFileMenu.spec.ts | 3 -- lib/dav/dav.ts | 2 -- lib/files/node.ts | 8 ----- lib/files/nodeData.ts | 22 ------------- 8 files changed, 125 deletions(-) diff --git a/__tests__/dav/dav.spec.ts b/__tests__/dav/dav.spec.ts index a4f534a5..dc986b3e 100644 --- a/__tests__/dav/dav.spec.ts +++ b/__tests__/dav/dav.spec.ts @@ -50,7 +50,6 @@ describe('davResultToNode', () => { expect(node.basename).toBe(result.basename) expect(node.extension).toBe('.md') expect(node.source).toBe('https://localhost/dav/files/test/New folder/Neue Textdatei.md') - expect(node.encodedSource).toBe('https://localhost/dav/files/test/New%20folder/Neue%20Textdatei.md') expect(node.root).toBe(davRootPath) expect(node.path).toBe('/New folder/Neue Textdatei.md') expect(node.dirname).toBe('/New folder') @@ -66,7 +65,6 @@ describe('davResultToNode', () => { expect(node.extension).toBe('.md') expect(node.root).toBe('/root') expect(node.source).toBe('https://localhost/dav/root/New folder/Neue Textdatei.md') - expect(node.encodedSource).toBe('https://localhost/dav/root/New%20folder/Neue%20Textdatei.md') expect(node.path).toBe('/New folder/Neue Textdatei.md') expect(node.dirname).toBe('/New folder') }) @@ -77,21 +75,9 @@ describe('davResultToNode', () => { expect(node.basename).toBe(remoteResult.basename) expect(node.extension).toBe('.md') expect(node.source).toBe('http://example.com/dav/root/New folder/Neue Textdatei.md') - expect(node.encodedSource).toBe('http://example.com/dav/root/New%20folder/Neue%20Textdatei.md') expect(node.path).toBe('/New folder/Neue Textdatei.md') expect(node.dirname).toBe('/New folder') }) - - test('encode special characters', () => { - const remoteResult = { ...result, basename: 'realy #1\'s.md', filename: '/root/~⛰️ shot of a $[big} mountain/realy #1\'s.md' } - const node = davResultToNode(remoteResult, '/root', 'http://example.com/dav') - expect(node.basename).toBe(remoteResult.basename) - expect(node.extension).toBe('.md') - expect(node.source).toBe('http://example.com/dav/root/~⛰️ shot of a $[big} mountain/realy #1\'s.md') - expect(node.encodedSource).toBe('http://example.com/dav/root/~%E2%9B%B0%EF%B8%8F%20shot%20of%20a%20%24%5Bbig%7D%20mountain/realy%20%231\'s.md') - expect(node.path).toBe('/~⛰️ shot of a $[big} mountain/realy #1\'s.md') - expect(node.dirname).toBe('/~⛰️ shot of a $[big} mountain') - }) }) describe('DAV requests', () => { diff --git a/__tests__/files/file.spec.ts b/__tests__/files/file.spec.ts index fc8e39f1..fa83e048 100644 --- a/__tests__/files/file.spec.ts +++ b/__tests__/files/file.spec.ts @@ -9,7 +9,6 @@ describe('File creation', () => { test('Valid dav file', () => { const file = new File({ source: 'https://cloud.domain.com/remote.php/dav/files/emma/Photos/picture.jpg', - encodedSource: 'https://cloud.domain.com/remote.php/dav/files/emma/Photos/picture.jpg', mime: 'image/jpeg', owner: 'emma', mtime: new Date(Date.UTC(2023, 0, 1, 0, 0, 0)), @@ -44,7 +43,6 @@ describe('File creation', () => { test('Valid dav file with root', () => { const file = new File({ source: 'https://cloud.domain.com/remote.php/dav/files/emma/Photos/picture.jpg', - encodedSource: 'https://cloud.domain.com/remote.php/dav/files/emma/Photos/picture.jpg', mime: 'image/jpeg', owner: 'emma', root: '/files/emma', @@ -72,7 +70,6 @@ describe('File creation', () => { test('Valid remote file', () => { const file = new File({ source: 'https://domain.com/Photos/picture.jpg', - encodedSource: 'https://domain.com/Photos/picture.jpg', mime: 'image/jpeg', owner: null, }) @@ -100,7 +97,6 @@ describe('File data change', () => { test('Rename a file', () => { const file = new File({ source: 'https://cloud.domain.com/remote.php/dav/files/emma/Photos/picture.jpg', - encodedSource: 'https://cloud.domain.com/remote.php/dav/files/emma/Photos/picture.jpg', mime: 'image/jpeg', owner: 'emma', mtime: new Date(Date.UTC(2023, 0, 1, 0, 0, 0)), @@ -125,7 +121,6 @@ describe('File data change', () => { test('Moving a file', () => { const file = new File({ source: 'https://cloud.domain.com/remote.php/dav/files/emma/Photos/picture.jpg', - encodedSource: 'https://cloud.domain.com/remote.php/dav/files/emma/Photos/picture.jpg', mime: 'image/jpeg', owner: 'emma', mtime: new Date(Date.UTC(2023, 0, 1, 0, 0, 0)), @@ -150,7 +145,6 @@ describe('File data change', () => { test('Moving a file to an invalid destination throws', () => { const file = new File({ source: 'https://cloud.domain.com/remote.php/dav/files/emma/Photos/picture.jpg', - encodedSource: 'https://cloud.domain.com/remote.php/dav/files/emma/Photos/picture.jpg', mime: 'image/jpeg', owner: 'emma', mtime: new Date(Date.UTC(2023, 0, 1, 0, 0, 0)), @@ -163,7 +157,6 @@ describe('File data change', () => { test('Moving a file to a different folder with root', () => { const file = new File({ source: 'https://cloud.domain.com/remote.php/dav/files/emma/Photos/picture.jpg', - encodedSource: 'https://cloud.domain.com/remote.php/dav/files/emma/Photos/picture.jpg', mime: 'image/jpeg', owner: 'emma', root: '/files/emma', @@ -184,7 +177,6 @@ describe('File data change', () => { test('Changing status', () => { const file = new File({ source: 'https://cloud.domain.com/remote.php/dav/files/emma/Photos/picture.jpg', - encodedSource: 'https://cloud.domain.com/remote.php/dav/files/emma/Photos/picture.jpg', mime: 'image/jpeg', owner: 'emma', root: '/files/emma', @@ -200,7 +192,6 @@ describe('Altering attributes updates mtime', () => { test('mtime is updated on existing attribute', () => { const file = new File({ source: 'https://cloud.domain.com/remote.php/dav/files/emma', - encodedSource: 'https://cloud.domain.com/remote.php/dav/files/emma', mime: 'image/jpeg', owner: 'emma', mtime: new Date(Date.UTC(1990, 0, 1, 0, 0, 0)), @@ -219,7 +210,6 @@ describe('Altering attributes updates mtime', () => { test('mtime is updated on new attribute', () => { const file = new File({ source: 'https://cloud.domain.com/remote.php/dav/files/emma', - encodedSource: 'https://cloud.domain.com/remote.php/dav/files/emma', mime: 'image/jpeg', owner: 'emma', mtime: new Date(Date.UTC(1990, 0, 1, 0, 0, 0)), @@ -235,7 +225,6 @@ describe('Altering attributes updates mtime', () => { test('mtime is updated on deleted attribute', () => { const file = new File({ source: 'https://cloud.domain.com/remote.php/dav/files/emma', - encodedSource: 'https://cloud.domain.com/remote.php/dav/files/emma', mime: 'image/jpeg', owner: 'emma', mtime: new Date(Date.UTC(1990, 0, 1, 0, 0, 0)), @@ -254,7 +243,6 @@ describe('Altering attributes updates mtime', () => { test('mtime is NOT updated if not initially defined', () => { const file = new File({ source: 'https://cloud.domain.com/remote.php/dav/files/emma', - encodedSource: 'https://cloud.domain.com/remote.php/dav/files/emma', mime: 'image/jpeg', owner: 'emma', attributes: { diff --git a/__tests__/files/folder.spec.ts b/__tests__/files/folder.spec.ts index 3e0834e4..6fd3f51b 100644 --- a/__tests__/files/folder.spec.ts +++ b/__tests__/files/folder.spec.ts @@ -8,7 +8,6 @@ describe('Folder creation', () => { test('Valid dav folder', () => { const folder = new Folder({ source: 'https://cloud.domain.com/remote.php/dav/files/emma/Photos/', - encodedSource: 'https://cloud.domain.com/remote.php/dav/files/emma/Photos/', owner: 'emma', }) @@ -33,7 +32,6 @@ describe('Folder creation', () => { test('Valid dav folder with root', () => { const folder = new Folder({ source: 'https://cloud.domain.com/remote.php/dav/files/emma/Photos/Berlin', - encodedSource: 'https://cloud.domain.com/remote.php/dav/files/emma/Photos/Berlin', owner: 'emma', root: '/files/emma', }) @@ -59,7 +57,6 @@ describe('Folder creation', () => { test('Valid remote folder', () => { const folder = new Folder({ source: 'https://domain.com/Photos/', - encodedSource: 'https://domain.com/Photos/', owner: null, }) @@ -86,7 +83,6 @@ describe('Folder data change', () => { test('Rename a folder', () => { const folder = new Folder({ source: 'https://cloud.domain.com/remote.php/dav/files/emma/Photos', - encodedSource: 'https://cloud.domain.com/remote.php/dav/files/emma/Photos', owner: 'emma', }) @@ -105,7 +101,6 @@ describe('Folder data change', () => { test('Moving a folder', () => { const folder = new Folder({ source: 'https://cloud.domain.com/remote.php/dav/files/emma/Photos/', - encodedSource: 'https://cloud.domain.com/remote.php/dav/files/emma/Photos/', owner: 'emma', }) @@ -124,7 +119,6 @@ describe('Folder data change', () => { test('Moving a folder to a different location with root', () => { const folder = new Folder({ source: 'https://cloud.domain.com/remote.php/dav/files/emma/Photos/', - encodedSource: 'https://cloud.domain.com/remote.php/dav/files/emma/Photos/', owner: 'emma', root: '/files/emma', }) diff --git a/__tests__/files/node.spec.ts b/__tests__/files/node.spec.ts index 5a7bd6bf..c77a14b6 100644 --- a/__tests__/files/node.spec.ts +++ b/__tests__/files/node.spec.ts @@ -10,7 +10,6 @@ describe('Node testing', () => { test('Root null fallback', () => { const file = new File({ source: 'https://cloud.domain.com/remote.php/dav/picture.jpg', - encodedSource: 'https://cloud.domain.com/remote.php/dav/picture.jpg', mime: 'image/jpeg', owner: 'emma', }) @@ -20,7 +19,6 @@ describe('Node testing', () => { test('Remove source ending slash', () => { const file = new Folder({ source: 'https://cloud.domain.com/remote.php/dav/files/emma/Photos/', - encodedSource: 'https://cloud.domain.com/remote.php/dav/picture.jpg', owner: 'emma', }) expect(file.source).toBe('https://cloud.domain.com/remote.php/dav/files/emma/Photos') @@ -29,7 +27,6 @@ describe('Node testing', () => { test('Invalid rename', () => { const file = new Folder({ source: 'https://cloud.domain.com/remote.php/dav/files/emma/Photos/', - encodedSource: 'https://cloud.domain.com/remote.php/dav/picture.jpg', owner: 'emma', }) expect(() => file.rename('new/folder')).toThrowError('Invalid basename') @@ -40,7 +37,6 @@ describe('FileId attribute', () => { test('FileId null fallback', () => { const file = new File({ source: 'https://cloud.domain.com/remote.php/dav/picture.jpg', - encodedSource: 'https://cloud.domain.com/remote.php/dav/picture.jpg', mime: 'image/jpeg', owner: 'emma', }) @@ -50,7 +46,6 @@ describe('FileId attribute', () => { test('FileId null fallback', () => { const file = new File({ source: 'https://cloud.domain.com/remote.php/dav/picture.jpg', - encodedSource: 'https://cloud.domain.com/remote.php/dav/picture.jpg', mime: 'image/jpeg', owner: 'emma', id: 1234, @@ -62,7 +57,6 @@ describe('FileId attribute', () => { test('FileId negative fallback', () => { const file = new File({ source: 'https://cloud.domain.com/remote.php/dav/picture.jpg', - encodedSource: 'https://cloud.domain.com/remote.php/dav/picture.jpg', mime: 'image/jpeg', owner: 'emma', id: -1234, @@ -73,7 +67,6 @@ describe('FileId attribute', () => { test('FileId attributes fallback', () => { const file = new Folder({ source: 'https://cloud.domain.com/remote.php/dav/files/emma/Photos/', - encodedSource: 'https://cloud.domain.com/remote.php/dav/files/emma/Photos/', mime: 'image/jpeg', owner: 'emma', attributes: { @@ -88,7 +81,6 @@ describe('Sanity checks', () => { test('Invalid id', () => { expect(() => new File({ source: 'https://cloud.domain.com/remote.php/dav/files/emma/Photos/picture.jpg', - encodedSource: 'https://cloud.domain.com/remote.php/dav/files/emma/Photos/picture.jpg', mime: 'image/jpeg', owner: 'emma', id: '1234' as unknown as number, @@ -99,46 +91,24 @@ describe('Sanity checks', () => { expect(() => new File({} as unknown as NodeData)).toThrowError('Missing mandatory source') expect(() => new File({ source: 'cloud.domain.com/remote.php/dav/Photos', - encodedSource: 'cloud.domain.com/remote.php/dav/Photos', mime: 'image/jpeg', owner: 'emma', })).toThrowError('Invalid source') expect(() => new File({ source: '/remote.php/dav/files/emma/Photos/picture.jpg', - encodedSource: '/remote.php/dav/files/emma/Photos/picture.jpg', mime: 'image/jpeg', owner: 'emma', })).toThrowError('Invalid source format, source must be a valid URL') expect(() => new File({ source: 'ftp://remote.php/dav/files/emma/Photos/picture.jpg', - encodedSource: 'ftp://remote.php/dav/files/emma/Photos/picture.jpg', mime: 'image/jpeg', owner: 'emma', })).toThrowError('Invalid source format, only http(s) is supported') }) - test('Invalid encodedSource', () => { - expect(() => new File({ - source: 'https://cloud.domain.com/remote.php/dav/files/emma/Photos/picture.jpg', - } as unknown as NodeData)).toThrowError('Missing mandatory encodedSource') - expect(() => new File({ - source: 'https://cloud.domain.com/remote.php/dav/files/emma/Photos/picture.jpg', - encodedSource: '/remote.php/dav/files/emma/Photos/picture.jpg', - mime: 'image/jpeg', - owner: 'emma', - })).toThrowError('Invalid encodedSource format, encodedSource must be a valid URL') - expect(() => new File({ - source: 'https://cloud.domain.com/remote.php/dav/files/emma/Photos/picture.jpg', - encodedSource: 'ftp://remote.php/dav/files/emma/Photos/picture.jpg', - mime: 'image/jpeg', - owner: 'emma', - })).toThrowError('Invalid encodedSource format, only http(s) is supported') - }) - test('Invalid mtime', () => { expect(() => new File({ source: 'https://cloud.domain.com/remote.php/dav/Photos', - encodedSource: 'https://cloud.domain.com/remote.php/dav/Photos', mime: 'image', owner: 'emma', mtime: 'invalid' as unknown as Date, @@ -148,7 +118,6 @@ describe('Sanity checks', () => { test('Invalid crtime', () => { expect(() => new File({ source: 'https://cloud.domain.com/remote.php/dav/Photos', - encodedSource: 'https://cloud.domain.com/remote.php/dav/Photos', mime: 'image', owner: 'emma', crtime: 'invalid' as unknown as Date, @@ -158,7 +127,6 @@ describe('Sanity checks', () => { test('Invalid mime', () => { expect(() => new File({ source: 'https://cloud.domain.com/remote.php/dav/files/emma/Photos/picture.jpg', - encodedSource: 'https://cloud.domain.com/remote.php/dav/files/emma/Photos/picture.jpg', mime: 'image', owner: 'emma', })).toThrowError('Missing or invalid mandatory mime') @@ -167,7 +135,6 @@ describe('Sanity checks', () => { test('Invalid attributes', () => { expect(() => new File({ source: 'https://cloud.domain.com/remote.php/dav/files/emma/Photos/picture.jpg', - encodedSource: 'https://cloud.domain.com/remote.php/dav/files/emma/Photos/picture.jpg', mime: 'image/jpeg', owner: 'emma', attributes: 'test' as unknown as Attribute, @@ -177,7 +144,6 @@ describe('Sanity checks', () => { test('Invalid permissions', () => { expect(() => new File({ source: 'https://cloud.domain.com/remote.php/dav/files/emma/Photos/picture.jpg', - encodedSource: 'https://cloud.domain.com/remote.php/dav/files/emma/Photos/picture.jpg', mime: 'image/jpeg', owner: 'emma', permissions: 324 as unknown as number, @@ -187,7 +153,6 @@ describe('Sanity checks', () => { test('Invalid size', () => { expect(() => new File({ source: 'https://cloud.domain.com/remote.php/dav/files/emma/Photos/picture.jpg', - encodedSource: 'https://cloud.domain.com/remote.php/dav/files/emma/Photos/picture.jpg', mime: 'image/jpeg', owner: 'emma', size: 'test' as unknown as number, @@ -197,7 +162,6 @@ describe('Sanity checks', () => { test('Invalid owner', () => { expect(() => new File({ source: 'https://cloud.domain.com/remote.php/dav/files/emma/Photos/picture.jpg', - encodedSource: 'https://cloud.domain.com/remote.php/dav/files/emma/Photos/picture.jpg', mime: 'image/jpeg', owner: true as unknown as string, })).toThrowError('Invalid owner') @@ -206,7 +170,6 @@ describe('Sanity checks', () => { test('Invalid root', () => { expect(() => new File({ source: 'https://cloud.domain.com/remote.php/dav/files/emma/Photos/picture.jpg', - encodedSource: 'https://cloud.domain.com/remote.php/dav/files/emma/Photos/picture.jpg', mime: 'image/jpeg', owner: 'emma', root: true as unknown as string, @@ -214,7 +177,6 @@ describe('Sanity checks', () => { expect(() => new File({ source: 'https://cloud.domain.com/remote.php/dav/files/emma/Photos/picture.jpg', - encodedSource: 'https://cloud.domain.com/remote.php/dav/files/emma/Photos/picture.jpg', mime: 'image/jpeg', owner: 'emma', root: 'https://cloud.domain.com/remote.php/dav/', @@ -222,7 +184,6 @@ describe('Sanity checks', () => { expect(() => new File({ source: 'https://cloud.domain.com/remote.php/dav/files/emma/Photos/picture.jpg', - encodedSource: 'https://cloud.domain.com/remote.php/dav/files/emma/Photos/picture.jpg', mime: 'image/jpeg', owner: 'emma', root: '/files/john', @@ -230,7 +191,6 @@ describe('Sanity checks', () => { expect(() => new File({ source: 'https://cloud.domain.com/remote.php/dav/files/emma/Photos/picture.jpg', - encodedSource: 'https://cloud.domain.com/remote.php/dav/files/emma/Photos/picture.jpg', mime: 'image/jpeg', owner: 'emma', root: '/remote.php/dav/files/emma', @@ -240,7 +200,6 @@ describe('Sanity checks', () => { test('Invalid status', () => { expect(() => new File({ source: 'https://cloud.domain.com/remote.php/dav/files/emma/Photos/picture.jpg', - encodedSource: 'https://cloud.domain.com/remote.php/dav/files/emma/Photos/picture.jpg', mime: 'image/jpeg', owner: 'emma', status: 'invalid' as unknown as NodeStatus, @@ -252,7 +211,6 @@ describe('Dav service detection', () => { test('Known dav services', () => { const file1 = new File({ source: 'https://cloud.domain.com/remote.php/dav/files/emma/Photos/picture.jpg', - encodedSource: 'https://cloud.domain.com/remote.php/dav/files/emma/Photos/picture.jpg', mime: 'image/jpeg', owner: 'emma', }) @@ -260,7 +218,6 @@ describe('Dav service detection', () => { const file2 = new File({ source: 'https://cloud.domain.com/remote.php/webdav/files/emma/Photos/picture.jpg', - encodedSource: 'https://cloud.domain.com/remote.php/webdav/files/emma/Photos/picture.jpg', mime: 'image/jpeg', owner: 'emma', }) @@ -268,7 +225,6 @@ describe('Dav service detection', () => { const file3 = new File({ source: 'https://cloud.domain.com/public.php/dav/files/emma/Photos/picture.jpg', - encodedSource: 'https://cloud.domain.com/public.php/dav/files/emma/Photos/picture.jpg', mime: 'image/jpeg', owner: 'emma', }) @@ -276,7 +232,6 @@ describe('Dav service detection', () => { const file4 = new File({ source: 'https://cloud.domain.com/public.php/webdav/files/emma/Photos/picture.jpg', - encodedSource: 'https://cloud.domain.com/public.php/webdav/files/emma/Photos/picture.jpg', mime: 'image/jpeg', owner: 'emma', }) @@ -286,7 +241,6 @@ describe('Dav service detection', () => { test('Custom dav service', () => { const file1 = new File({ source: 'https://cloud.domain.com/test.php/dav/files/emma/Photos/picture.jpg', - encodedSource: 'https://cloud.domain.com/test.php/dav/files/emma/Photos/picture.jpg', mime: 'image/jpeg', owner: 'emma', }, /test\.php\/dav/) @@ -294,7 +248,6 @@ describe('Dav service detection', () => { const file2 = new File({ source: 'https://cloud.domain.com/remote.php/dav/files/emma/Photos/picture.jpg', - encodedSource: 'https://cloud.domain.com/remote.php/dav/files/emma/Photos/picture.jpg', mime: 'image/jpeg', owner: 'emma', }, /test\.php\/dav/) @@ -306,7 +259,6 @@ describe('Permissions handling', () => { test('Default permissions', () => { const file = new File({ source: 'https://cloud.domain.com/remote.php/dav/files/emma/Photos/picture.jpg', - encodedSource: 'https://cloud.domain.com/remote.php/dav/files/emma/Photos/picture.jpg', mime: 'image/jpeg', owner: 'emma', }) @@ -316,7 +268,6 @@ describe('Permissions handling', () => { test('Custom permissions', () => { const file = new File({ source: 'https://cloud.domain.com/remote.php/dav/files/emma/Photos/picture.jpg', - encodedSource: 'https://cloud.domain.com/remote.php/dav/files/emma/Photos/picture.jpg', mime: 'image/jpeg', owner: 'emma', permissions: Permission.READ | Permission.UPDATE | Permission.CREATE | Permission.DELETE | Permission.SHARE, @@ -329,7 +280,6 @@ describe('Root and paths detection', () => { test('Unknown root', () => { const file = new File({ source: 'https://cloud.domain.com/remote.php/dav/files/emma/Photos/picture.jpg', - encodedSource: 'https://cloud.domain.com/remote.php/dav/files/emma/Photos/picture.jpg', mime: 'image/jpeg', owner: 'emma', }) @@ -340,7 +290,6 @@ describe('Root and paths detection', () => { test('Provided root dav service', () => { const file = new File({ source: 'https://cloud.domain.com/remote.php/dav/files/emma/Photos/picture.jpg', - encodedSource: 'https://cloud.domain.com/remote.php/dav/files/emma/Photos/picture.jpg', mime: 'image/jpeg', owner: 'emma', root: '/files/emma', @@ -352,7 +301,6 @@ describe('Root and paths detection', () => { test('Root with ending slash is removed', () => { const file = new File({ source: 'https://cloud.domain.com/remote.php/dav/files/emma/Photos/picture.jpg', - encodedSource: 'https://cloud.domain.com/remote.php/dav/files/emma/Photos/picture.jpg', mime: 'image/jpeg', owner: 'emma', root: '/files/emma/', @@ -365,7 +313,6 @@ describe('Root and paths detection', () => { test('Root and source are the same', () => { const folder = new Folder({ source: 'https://cloud.domain.com/remote.php/dav/files/emma', - encodedSource: 'https://cloud.domain.com/remote.php/dav/files/emma', owner: 'emma', root: '/files/emma', }) @@ -377,7 +324,6 @@ describe('Root and paths detection', () => { test('Source contains a similar root path', () => { const folder = new Folder({ source: 'https://domain.com/remote.php/dav/files/emma/files/emma', - encodedSource: 'https://domain.com/remote.php/dav/files/emma/files/emma', owner: 'emma', root: '/files/emma', }) @@ -387,7 +333,6 @@ describe('Root and paths detection', () => { const file = new File({ source: 'https://domain.com/remote.php/dav/files/emma/files/emma.jpeg', - encodedSource: 'https://domain.com/remote.php/dav/files/emma/files/emma.jpeg', mime: 'image/jpeg', owner: 'emma', root: '/files/emma', @@ -400,7 +345,6 @@ describe('Root and paths detection', () => { test('Non dav ressource with undefined root', () => { const file = new File({ source: 'https://domain.com/files/images/emma.jpeg', - encodedSource: 'https://domain.com/files/images/emma.jpeg', mime: 'image/jpeg', owner: 'emma', }) @@ -415,7 +359,6 @@ describe('Undefined properties are allowed', () => { test('File', () => { expect(() => new File({ source: 'https://domain.com/files/images/emma.jpeg', - encodedSource: 'https://domain.com/files/images/emma.jpeg', owner: 'emma', id: undefined, mtime: undefined, @@ -432,7 +375,6 @@ describe('Undefined properties are allowed', () => { test('Folder', () => { expect(() => new Folder({ source: 'https://domain.com/files/images/', - encodedSource: 'https://domain.com/files/images/', owner: 'emma', id: undefined, mtime: undefined, diff --git a/__tests__/newFileMenu.spec.ts b/__tests__/newFileMenu.spec.ts index b286f4a2..8a7054ad 100644 --- a/__tests__/newFileMenu.spec.ts +++ b/__tests__/newFileMenu.spec.ts @@ -265,7 +265,6 @@ describe('NewFileMenu getEntries filter', () => { owner: 'admin', size: 2610077102, source: 'https://example.com/remote.php/dav/files/admin/Folder', - encodedSource: 'https://example.com/remote.php/dav/files/admin/Folder', permissions: Permission.ALL, }) @@ -302,7 +301,6 @@ describe('NewFileMenu getEntries filter', () => { owner: 'admin', size: 2610077102, source: 'https://example.com/remote.php/dav/files/admin/Folder', - encodedSource: 'https://example.com/remote.php/dav/files/admin/Folder', permissions: Permission.READ, }) @@ -336,7 +334,6 @@ describe('NewFileMenu getEntries filter', () => { owner: 'admin', size: 2610077102, source: 'https://example.com/remote.php/dav/files/admin/Foo/Bar', - encodedSource: 'https://example.com/remote.php/dav/files/admin/Foo/Bar', permissions: Permission.NONE, root: '/files/admin', }) diff --git a/lib/dav/dav.ts b/lib/dav/dav.ts index aeac227d..8279a5d9 100644 --- a/lib/dav/dav.ts +++ b/lib/dav/dav.ts @@ -33,7 +33,6 @@ import { getCurrentUser, getRequestToken } from '@nextcloud/auth' import { generateRemoteUrl } from '@nextcloud/router' import { createClient, getPatcher, RequestOptions } from 'webdav' import { request } from 'webdav/dist/node/request.js' -import { encodePath } from 'webdav/dist/node/tools/path.js' /** * Nextcloud DAV result response @@ -133,7 +132,6 @@ export const davResultToNode = function(node: FileStat, filesRoot = davRootPath, const nodeData: NodeData = { id: (props?.fileid as number) || 0, source: `${remoteURL}${node.filename}`, - encodedSource: `${remoteURL}${encodePath(node.filename)}`, mtime: new Date(Date.parse(node.lastmod)), mime: node.mime as string, size: props?.size || Number.parseInt(props.getcontentlength || '0'), diff --git a/lib/files/node.ts b/lib/files/node.ts index c59b4eef..e3dbc66b 100644 --- a/lib/files/node.ts +++ b/lib/files/node.ts @@ -82,14 +82,6 @@ export abstract class Node { return this._data.source.replace(/\/$/i, '') } - /** - * Get the encoded source url to this object - */ - get encodedSource(): string { - // strip any ending slash - return this._data.encodedSource.replace(/\/$/i, '') - } - /** * Get this object name */ diff --git a/lib/files/nodeData.ts b/lib/files/nodeData.ts index 12a4c2ae..b0d241bf 100644 --- a/lib/files/nodeData.ts +++ b/lib/files/nodeData.ts @@ -37,13 +37,6 @@ export interface NodeData { */ source: string - /** - * Percent encoded URL to the ressource. - * e.g. https://cloud.domain.com/remote.php/dav/files/emma/Photos/picture_with_%23.jpg - * or https://domain.com/Photos/picture_with_%23.jpg - */ - encodedSource: string - /** Last modified time */ mtime?: Date @@ -101,10 +94,6 @@ export const validateData = (data: NodeData, davService: RegExp) => { throw new Error('Missing mandatory source') } - if (!data.encodedSource) { - throw new Error('Missing mandatory encodedSource') - } - try { // eslint-disable-next-line no-new new URL(data.source) @@ -112,21 +101,10 @@ export const validateData = (data: NodeData, davService: RegExp) => { throw new Error('Invalid source format, source must be a valid URL') } - try { - // eslint-disable-next-line no-new - new URL(data.encodedSource) - } catch (e) { - throw new Error('Invalid encodedSource format, encodedSource must be a valid URL') - } - if (!data.source.startsWith('http')) { throw new Error('Invalid source format, only http(s) is supported') } - if (!data.encodedSource.startsWith('http')) { - throw new Error('Invalid encodedSource format, only http(s) is supported') - } - if (data.mtime && !(data.mtime instanceof Date)) { throw new Error('Invalid mtime type') }