mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-17 17:11:38 +00:00
15 lines
370 B
TypeScript
15 lines
370 B
TypeScript
/** Strip username/password credentials from a URL string when it parses. */
|
|
export function stripUrlUserInfo(value: string): string {
|
|
try {
|
|
const parsed = new URL(value);
|
|
if (!parsed.username && !parsed.password) {
|
|
return value;
|
|
}
|
|
parsed.username = "";
|
|
parsed.password = "";
|
|
return parsed.toString();
|
|
} catch {
|
|
return value;
|
|
}
|
|
}
|