1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-06-15 23:00:36 +02:00

Various tweaks to get Nextcloud working in mobile

This commit is contained in:
Laurent Cozic
2018-01-25 19:01:14 +00:00
parent 1cc27f2509
commit 7ab135c099
16 changed files with 250 additions and 38 deletions

View File

@ -28,7 +28,19 @@ function shimInit() {
shim.fetch = async function(url, options = null) {
return shim.fetchWithRetry(() => {
return shim.nativeFetch_(url, options)
// The native fetch() throws an uncatable error if calling it with an invalid URL
// such as '//.resource' so detect if the URL is valid beforehand and throw
// a catchable error.
if (typeof url !== 'string') {
console.info('NOT A STRING: ', url);
throw new Error('shim.fetch: URL is not a string');
}
const lcUrl = url.toLowerCase();
if (lcUrl.indexOf('http:') !== 0 && lcUrl.indexOf('https:') !== 0) throw new Error('shim.fetch: Invalid URL: ' + lcUrl);
return shim.nativeFetch_(url, options);
}, options);
}