Files
openclaw/src/infra/google-api-base-url.test.ts
Vincent Koc 0e9a9dae84 fix(providers): centralize Google endpoint classification (#59556)
* fix(providers): centralize Google endpoint classification

* fix(providers): tighten Google endpoint fallback parsing

* fix(security): harden provider endpoint fallback parsing
2026-04-02 19:21:31 +09:00

38 lines
1.2 KiB
TypeScript

import { describe, expect, it } from "vitest";
import { DEFAULT_GOOGLE_API_BASE_URL, normalizeGoogleApiBaseUrl } from "./google-api-base-url.js";
describe("normalizeGoogleApiBaseUrl", () => {
it("defaults to the Gemini v1beta API root", () => {
expect(normalizeGoogleApiBaseUrl()).toBe(DEFAULT_GOOGLE_API_BASE_URL);
});
it.each([
{
value: "https://generativelanguage.googleapis.com",
expected: DEFAULT_GOOGLE_API_BASE_URL,
},
{
value: "https://generativelanguage.googleapis.com/",
expected: DEFAULT_GOOGLE_API_BASE_URL,
},
{
value: "https://generativelanguage.googleapis.com/v1beta",
expected: DEFAULT_GOOGLE_API_BASE_URL,
},
{
value: "https://generativelanguage.googleapis.com/v1",
expected: "https://generativelanguage.googleapis.com/v1",
},
{
value: "https://proxy.example.com/google/v1beta/",
expected: "https://proxy.example.com/google/v1beta",
},
{
value: "generativelanguage.googleapis.com",
expected: "generativelanguage.googleapis.com",
},
])("normalizes %s", ({ value, expected }) => {
expect(normalizeGoogleApiBaseUrl(value)).toBe(expected);
});
});