1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-24 10:27:10 +02:00

Mobile: Fixes #531: Get WebDAV to work with certain servers that require a trailing slash on directories

This commit is contained in:
Laurent Cozic 2018-05-22 15:55:38 +01:00 committed by GitHub
parent 6898b9ca4c
commit 86e3038cfe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -299,6 +299,11 @@ class FileApiDriverWebDav {
async mkdir(path) { async mkdir(path) {
try { try {
// RFC wants this, and so does NGINX. Not having the trailing slash means that some
// WebDAV implementations will redirect to a URL with "/". However, when doing so
// in React Native, the auth headers, etc. are lost so we need to avoid this.
// https://github.com/facebook/react-native/issues/929
if (!path.endsWith('/')) path = path + '/';
await this.api().exec('MKCOL', path); await this.api().exec('MKCOL', path);
} catch (error) { } catch (error) {
if (error.code === 405) return; // 405 means that the collection already exists (Method Not Allowed) if (error.code === 405) return; // 405 means that the collection already exists (Method Not Allowed)
@ -345,4 +350,4 @@ class FileApiDriverWebDav {
} }
module.exports = { FileApiDriverWebDav }; module.exports = { FileApiDriverWebDav };