mirror of
https://github.com/farcasclaudiu/openclaw.git
synced 2026-06-28 19:01:47 +03:00
chore: Enable "curly" rule to avoid single-statement if confusion/errors.
This commit is contained in:
@@ -22,7 +22,9 @@ export function getDefaultCopilotModelIds(): string[] {
|
||||
|
||||
export function buildCopilotModelDefinition(modelId: string): ModelDefinitionConfig {
|
||||
const id = modelId.trim();
|
||||
if (!id) throw new Error("Model id required");
|
||||
if (!id) {
|
||||
throw new Error("Model id required");
|
||||
}
|
||||
return {
|
||||
id,
|
||||
name: id,
|
||||
|
||||
@@ -57,18 +57,24 @@ export const DEFAULT_COPILOT_API_BASE_URL = "https://api.individual.githubcopilo
|
||||
|
||||
export function deriveCopilotApiBaseUrlFromToken(token: string): string | null {
|
||||
const trimmed = token.trim();
|
||||
if (!trimmed) return null;
|
||||
if (!trimmed) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// The token returned from the Copilot token endpoint is a semicolon-delimited
|
||||
// set of key/value pairs. One of them is `proxy-ep=...`.
|
||||
const match = trimmed.match(/(?:^|;)\s*proxy-ep=([^;\s]+)/i);
|
||||
const proxyEp = match?.[1]?.trim();
|
||||
if (!proxyEp) return null;
|
||||
if (!proxyEp) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// pi-ai expects converting proxy.* -> api.*
|
||||
// (see upstream getGitHubCopilotBaseUrl).
|
||||
const host = proxyEp.replace(/^https?:\/\//, "").replace(/^proxy\./i, "api.");
|
||||
if (!host) return null;
|
||||
if (!host) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return `https://${host}`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user