fix(quality): explicit promise-existence checks + protocol-aware WebDAV URL

SonarCloud new-code findings:
- combo.ts / sync-models route: `if (cachedPromise)` -> `!= null` (intentional
  in-flight-promise reuse; explicit existence check, no behaviour change).
- ObsidianSourceCard WebDAV URL: inherit window.location.protocol instead of
  hard-coding http:// (https when behind a TLS proxy) — clears the http hotspot.
This commit is contained in:
diegosouzapw
2026-06-03 23:53:03 -03:00
parent dd85309e64
commit b6bda19919
3 changed files with 7 additions and 6 deletions

View File

@@ -1761,7 +1761,7 @@ async function fetchResetAwareQuotaWithCache({
const refresh = () => {
const existing = resetAwareQuotaCache.get(cacheKey);
if (existing?.refreshPromise) return existing.refreshPromise;
if (existing?.refreshPromise != null) return existing.refreshPromise;
const refreshPromise = fetcher(connectionId, connection)
.then((quota) => {

View File

@@ -165,10 +165,11 @@ export default function ObsidianSourceCard() {
};
const getWebdavUrl = (): string => {
if (typeof window === "undefined") return "http://<server-ip>/api/v1/webdav/";
const host = window.location.hostname;
const port = window.location.port;
return `http://${host}:${port}/api/v1/webdav`;
if (typeof window === "undefined") return "<server-ip>/api/v1/webdav/";
// Inherit the page protocol (http on localhost, https behind a TLS proxy)
// instead of hard-coding http.
const { protocol, hostname, port } = window.location;
return `${protocol}//${hostname}:${port}/api/v1/webdav`;
};
return (

View File

@@ -174,7 +174,7 @@ export type EnsureReadyOptions = {
};
export async function ensureLoopbackServerReady(opts: EnsureReadyOptions = {}): Promise<void> {
if (__loopbackReadyPromise) return __loopbackReadyPromise;
if (__loopbackReadyPromise != null) return __loopbackReadyPromise;
__loopbackReadyPromise = (async () => {
const f = opts.fetch ?? fetch;
const maxWaitMs = opts.maxWaitMs ?? 30_000;