From 86e3038cfe5f174d874fb178f4f7aa547bfdc27b Mon Sep 17 00:00:00 2001 From: Laurent Cozic Date: Tue, 22 May 2018 15:55:38 +0100 Subject: [PATCH] Mobile: Fixes #531: Get WebDAV to work with certain servers that require a trailing slash on directories --- ReactNativeClient/lib/file-api-driver-webdav.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ReactNativeClient/lib/file-api-driver-webdav.js b/ReactNativeClient/lib/file-api-driver-webdav.js index cec088d563..f8aed47edd 100644 --- a/ReactNativeClient/lib/file-api-driver-webdav.js +++ b/ReactNativeClient/lib/file-api-driver-webdav.js @@ -299,6 +299,11 @@ class FileApiDriverWebDav { async mkdir(path) { 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); } catch (error) { if (error.code === 405) return; // 405 means that the collection already exists (Method Not Allowed) @@ -345,4 +350,4 @@ class FileApiDriverWebDav { } -module.exports = { FileApiDriverWebDav }; \ No newline at end of file +module.exports = { FileApiDriverWebDav };