Skip to content

Commit

Permalink
All: Fixes #808 (maybe): Added fix for Nginx 404 error issue.
Browse files Browse the repository at this point in the history
  • Loading branch information
laurent22 committed Dec 6, 2018
1 parent 18d7680 commit 3943192
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions ReactNativeClient/lib/WebDavApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,17 @@ class WebDavApi {

const output = await loadResponseJson();

// Trying to fix 404 error issue with Nginx WebDAV server.
// https://github.com/laurent22/joplin/issues/624
// https://github.com/laurent22/joplin/issues/808
// Not tested but someone confirmed it worked - https://github.com/laurent22/joplin/issues/808#issuecomment-443552858
// and fix is narrowly scoped so shouldn't affect anything outside this particular edge case.
const responseArray = this.arrayFromJson(output, ['d:multistatus', 'd:response']);
if (responseArray && responseArray.length === 1) {
const status = this.stringFromJson(output, ['d:multistatus', 'd:response', 0, 'd:propstat', 0, 'd:status', 0]);
if (status && status.indexOf('404') >= 0) throw newError('Not found', 404);
}

// Check that we didn't get for example an HTML page (as an error) instead of the JSON response
// null responses are possible, for example for DELETE calls
if (output !== null && typeof output === 'object' && !('d:multistatus' in output)) throw newError('Not a valid WebDAV response');
Expand Down

0 comments on commit 3943192

Please sign in to comment.