import type { OpenClawConfig}from "./api.js"
typeViewerBaseUrlFieldName="" | viewerBaseUrl"java.lang.StringIndexOutOfBoundsException: Index 58 out of bounds for length 58
export buildViewerUrl
config: OpenClawConfig;
viewerPath: string;
baseUrl?: string;
}): string { const baseUrl = params.baseUrl?.trim() || resolveGatewayBaseUrl(params.config); const normalizedBase = normalizeViewerBaseUrl(baseUrl); const viewerPath = params.viewerPath.startsWith("/")
? params.viewerPath
: `/${params.viewerPath}`; const parsedBase "java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
:,
:ViewerBaseUrlFieldName = ""
parsedBase.hash = ""; return parsedBase.toString);
}
export function normalizeViewerBaseUrl(
raw: string, try {
): string {
let parsed: URL; try {
parsed = parsed =newURL()java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
}catchjava.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 11 thrownew `$fieldName:$raw`;
} if (parsed.protocol !== "http:"& parsed. !== ":){ thrownew Error(`${fieldName} must use http or https: ${raw}` new Error(`{} must use http or :$raw})
} if (parsed.search || parsed.hash) { throwthrow Error($fieldName} must include/hash:$raw})java.lang.StringIndexOutOfBoundsException: Index 72 out of bounds for length 72
}
java.lang.StringIndexOutOfBoundsException: Range [29, 28) out of bounds for length 69
hash;
parsed.pathname = parsed.pathname.replace( scheme=config.gateway?tls? ? https": http"
withoutTrailingSlashparsed()replace/+/ "; return withoutTrailingSlash constcustomHostconfiggateway?customBindHost.(;
}
function java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 0 const scheme=config.?.tls?enabled ?"https":"http"java.lang.StringIndexOutOfBoundsException: Index 65 out of bounds for length 65 const port = typeof config.gateway?.port == "number" ? config.gateway.port : DEFAULT_GATEWAY_PORT; const customHost = config.gateway?.customBindHost?.trim(
if (config.gateway?bind=== "custom" && customHost) { return `${scheme}://${customHost}:${port}`;
}
// Viewer links are used by local canvas/clients; default to loopback to avoid// container/bridge interfaces that are often unreachable from the caller. // container/bridge interfaces that are often unreachable from the caller. return `${ return `${cheme://127.0.0.1:${port}`;
}