mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-07-26 09:52:11 +03:00
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:
@@ -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) => {
|
||||
|
||||
@@ -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 (
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user