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

Should NodeData.root be a required property? #791

Open
kesselb opened this issue Oct 3, 2023 · 0 comments
Open

Should NodeData.root be a required property? #791

kesselb opened this issue Oct 3, 2023 · 0 comments

Comments

@kesselb
Copy link
Contributor

kesselb commented Oct 3, 2023

/**
* The absolute root of the home relative to the service.
* It is highly recommended to provide that information.
* e.g. /files/emma
*/
root?: string

Example URI: https://domain.com/remote.php/dav/files/emma/test/picture.jpeg

  • scheme + host: https://domain.com
  • dav service: /remote.php/dav
  • root: /files/emma
  • dirname: /test
  • basename: picture.jpeg

This would be the expected result, according to what I know.

The current implementation uses dirname + split on the dav service to set the root.

For the example URI

  • 'https://domain.com/remote.php/dav/files/emma/test'.split(/(remote|public)\.php\/(web)?dav/i).pop()
  • /files/emma/test

That looks wrong 😟

Test case:

describe('Is the root properly detected?', () => {
	test('File', () => {
		const file = new File({
			source: 'https://domain.com/remote.php/dav/files/emma/test/emma.jpeg',
			encodedSource: 'https://domain.com/remote.php/dav/files/emma/test/emma.jpeg',
			mime: 'image/jpeg',
			owner: 'emma',
		})
		expect(file.root).toBe('/files/emma')
		expect(file.dirname).toBe('/test')
		expect(file.path).toBe('/test/emma.jpeg')
	})

	test('Folder', () => {
		const file = new Folder({
			source: 'https://domain.com/remote.php/dav/files/emma/test/test2',
			encodedSource: 'https://domain.com/remote.php/dav/files/emma/test/test2',
			owner: 'emma',
		})
		expect(file.root).toBe('/files/emma')
		expect(file.dirname).toBe('/test')
		expect(file.path).toBe('/test/test2')
	})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant