mirror of
https://github.com/vrtmrz/obsidian-livesync.git
synced 2026-09-21 01:57:05 +00:00
22 lines
804 B
TypeScript
22 lines
804 B
TypeScript
import type { RemoteConnectionProbe, RemoteConnectionProbeResult } from "@vrtmrz/livesync-commonlib/replication";
|
|
import { withOwnedRemoteResource } from "@/common/ownedRemoteResource";
|
|
|
|
/** Run the selected CouchDB setup mode within one owned probe lifetime. */
|
|
export async function probeCouchDBConnection(
|
|
probe: RemoteConnectionProbe,
|
|
createIfMissing: boolean
|
|
): Promise<RemoteConnectionProbeResult> {
|
|
return await withOwnedRemoteResource(probe, (ownedProbe) =>
|
|
ownedProbe.check({ createIfMissing, showResult: false })
|
|
);
|
|
}
|
|
|
|
export function isValidCouchDBServerURL(value: string): boolean {
|
|
try {
|
|
const url = new URL(value);
|
|
return (url.protocol === "http:" || url.protocol === "https:") && url.hostname !== "";
|
|
} catch {
|
|
return false;
|
|
}
|
|
}
|