mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-16 12:30:49 +00:00
Landed from contributor PR #30932 by @haosenwang1018. Co-authored-by: haosenwang1018 <haosenwang1018@users.noreply.github.com>
24 lines
570 B
TypeScript
24 lines
570 B
TypeScript
export function splitTrailingAuthProfile(raw: string): {
|
|
model: string;
|
|
profile?: string;
|
|
} {
|
|
const trimmed = raw.trim();
|
|
if (!trimmed) {
|
|
return { model: "" };
|
|
}
|
|
|
|
const lastSlash = trimmed.lastIndexOf("/");
|
|
const profileDelimiter = trimmed.indexOf("@", lastSlash + 1);
|
|
if (profileDelimiter <= 0) {
|
|
return { model: trimmed };
|
|
}
|
|
|
|
const model = trimmed.slice(0, profileDelimiter).trim();
|
|
const profile = trimmed.slice(profileDelimiter + 1).trim();
|
|
if (!model || !profile) {
|
|
return { model: trimmed };
|
|
}
|
|
|
|
return { model, profile };
|
|
}
|