Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/adapters/anthropic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,10 @@ export function applyAnthropicOAuthAuth(headers: Record<string, string>, accessT
/** The provider's Messages endpoint, refusing a base URL with an unresolved `{placeholder}`. */
export function resolveAnthropicMessagesUrl(provider: Pick<OcxProviderConfig, "baseUrl">): string {
const url = anthropicMessagesUrl(provider.baseUrl);
const unresolvedPlaceholder = url.match(/\{[^}]*\}/)?.[0];
// indexOf instead of a regex: \{[^}]*\} is quadratic on brace-only input (CodeQL js/polynomial-redos).
const openBrace = url.indexOf("{");
const closeBrace = openBrace === -1 ? -1 : url.indexOf("}", openBrace);
const unresolvedPlaceholder = closeBrace === -1 ? undefined : url.slice(openBrace, closeBrace + 1);
if (unresolvedPlaceholder) {
throw new Error(`anthropic baseUrl contains unresolved ${unresolvedPlaceholder}`);
}
Expand Down
Loading