mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-21 01:07:46 +00:00
Refactor: Improve env var resolution in settings
Refactors the `resolveEnvVarsInObject` function in settings to explicitly handle primitive types (null, undefined, boolean, number) at the beginning of the function. This clarifies the logic for subsequent string, array, and object processing.
This commit is contained in:
@@ -110,6 +110,15 @@ function resolveEnvVarsInString(value: string): string {
|
||||
}
|
||||
|
||||
function resolveEnvVarsInObject<T>(obj: T): T {
|
||||
if (
|
||||
obj === null ||
|
||||
obj === undefined ||
|
||||
typeof obj === 'boolean' ||
|
||||
typeof obj === 'number'
|
||||
) {
|
||||
return obj;
|
||||
}
|
||||
|
||||
if (typeof obj === 'string') {
|
||||
return resolveEnvVarsInString(obj) as unknown as T;
|
||||
}
|
||||
@@ -118,7 +127,7 @@ function resolveEnvVarsInObject<T>(obj: T): T {
|
||||
return obj.map((item) => resolveEnvVarsInObject(item)) as unknown as T;
|
||||
}
|
||||
|
||||
if (obj && typeof obj === 'object') {
|
||||
if (typeof obj === 'object') {
|
||||
const newObj = { ...obj } as T;
|
||||
for (const key in newObj) {
|
||||
if (Object.prototype.hasOwnProperty.call(newObj, key)) {
|
||||
|
||||
Reference in New Issue
Block a user