fix(model): land #30932 auth-profile @ parsing for /model (@haosenwang1018)

Landed from contributor PR #30932 by @haosenwang1018.

Co-authored-by: haosenwang1018 <haosenwang1018@users.noreply.github.com>
This commit is contained in:
Peter Steinberger
2026-03-02 03:04:16 +00:00
parent 15c1c93a95
commit e4e5d9c98c
5 changed files with 19 additions and 7 deletions

View File

@@ -46,4 +46,11 @@ describe("splitTrailingAuthProfile", () => {
model: "provider/foo@bar/baz",
});
});
it("uses first @ after last slash for email-based auth profiles", () => {
expect(splitTrailingAuthProfile("flash@google-gemini-cli:test@gmail.com")).toEqual({
model: "flash",
profile: "google-gemini-cli:test@gmail.com",
});
});
});

View File

@@ -7,9 +7,9 @@ export function splitTrailingAuthProfile(raw: string): {
return { model: "" };
}
const profileDelimiter = trimmed.lastIndexOf("@");
const lastSlash = trimmed.lastIndexOf("/");
if (profileDelimiter <= 0 || profileDelimiter <= lastSlash) {
const profileDelimiter = trimmed.indexOf("@", lastSlash + 1);
if (profileDelimiter <= 0) {
return { model: trimmed };
}