1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-01-02 12:47:41 +02:00

Desktop,Mobile,Cli: Fixes #10608: WebDAV synchronisation not working because of URL encoding differences (#11076)

This commit is contained in:
pedr 2024-09-23 14:19:51 -03:00 committed by GitHub
parent 85c2eb43dd
commit e3576683b0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 33 additions and 0 deletions

View File

@ -953,6 +953,7 @@ packages/lib/eventManager.js
packages/lib/file-api-driver-joplinServer.js
packages/lib/file-api-driver-local.js
packages/lib/file-api-driver-memory.js
packages/lib/file-api-driver-webdav.test.js
packages/lib/file-api-driver.test.js
packages/lib/file-api.test.js
packages/lib/file-api.js

1
.gitignore vendored
View File

@ -930,6 +930,7 @@ packages/lib/eventManager.js
packages/lib/file-api-driver-joplinServer.js
packages/lib/file-api-driver-local.js
packages/lib/file-api-driver-memory.js
packages/lib/file-api-driver-webdav.test.js
packages/lib/file-api-driver.test.js
packages/lib/file-api.test.js
packages/lib/file-api.js

View File

@ -107,6 +107,8 @@ class FileApiDriverWebDav {
output = href.substr(baseUrl.length);
} else if (href.indexOf(relativeBaseUrl) === 0) {
output = href.substr(relativeBaseUrl.length);
} else if (decodeURIComponent(href).indexOf(decodeURIComponent(relativeBaseUrl)) === 0) {
output = decodeURIComponent(href).substring(decodeURIComponent(relativeBaseUrl).length);
} else {
throw new Error(`href ${href} not in baseUrl ${baseUrl} nor relativeBaseUrl ${relativeBaseUrl}`);
}

View File

@ -0,0 +1,29 @@
const { FileApiDriverWebDav } = require('./file-api-driver-webdav');
describe('file-api-driver-webdav', () => {
it.each([
[
'/remote.php/dav/files/user@mail.com/Joplin/',
'/remote.php/dav/files/user%40mail.com/Joplin',
'',
],
[
'/remote.php/dav/files/user@mail.com/Joplin/.lock',
'/remote.php/dav/files/user%40mail.com/Joplin',
'.lock',
],
[
'/remote.php/dav/files/user@mail.com/joplin%20files/locks/',
'/remote.php/dav/files/user%40mail.com/joplin files',
'locks',
],
])('should return relative path even if encoding is different', (async (href: string, relativePath: string, result: string) => {
const driver = new FileApiDriverWebDav();
const baseUrl = 'https://use07.thegood.cloud/remote.php/dav/files/user%40mail.com/Joplin';
expect(driver.hrefToRelativePath_(href, baseUrl, relativePath)).toBe(result);
}));
});