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

34 lines
1020 B
TypeScript
Raw Normal View History

import { _ } from '../locale';
import Setting from '../models/Setting';
2023-05-29 13:20:56 +02:00
import { URL } from 'url';
const pathContainsUnsupportedProvider = (path: string, unsupportedProviders: string[]) => {
try {
const url = new URL(path.toLowerCase());
const splitted = url.host.split('.');
for (const s of splitted) {
if (unsupportedProviders.includes(s)) return true;
}
return false;
} catch (error) {
// The URL is probably invalid, but it's not here that we should handle
// this.
return false;
}
};
export const checkProviderIsSupported = (path: string): void => {
if (Setting.value('sync.allowUnsupportedProviders') === 1) return;
const unsupportedProviders = ['jianguoyun'];
for (const p of unsupportedProviders) {
2023-05-29 13:20:56 +02:00
if (pathContainsUnsupportedProvider(path, unsupportedProviders)) {
throw new Error(_('The WebDAV implementation of %s is incompatible with Joplin, and as such is no longer supported. Please use a different sync method.', p));
}
}
};
export default checkProviderIsSupported;