mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-10 00:23:29 +00:00
refactor: centralize isPlainObject, isRecord, isErrno, isLoopbackHost utilities (#12926)
This commit is contained in:
@@ -22,6 +22,8 @@
|
||||
|
||||
// Pattern for valid uppercase env var names: starts with letter or underscore,
|
||||
// followed by letters, numbers, or underscores (all uppercase)
|
||||
import { isPlainObject } from "../utils.js";
|
||||
|
||||
const ENV_VAR_NAME_PATTERN = /^[A-Z_][A-Z0-9_]*$/;
|
||||
|
||||
export class MissingEnvVarError extends Error {
|
||||
@@ -34,15 +36,6 @@ export class MissingEnvVarError extends Error {
|
||||
}
|
||||
}
|
||||
|
||||
function isPlainObject(value: unknown): value is Record<string, unknown> {
|
||||
return (
|
||||
typeof value === "object" &&
|
||||
value !== null &&
|
||||
!Array.isArray(value) &&
|
||||
Object.prototype.toString.call(value) === "[object Object]"
|
||||
);
|
||||
}
|
||||
|
||||
function substituteString(value: string, env: NodeJS.ProcessEnv, configPath: string): string {
|
||||
if (!value.includes("$")) {
|
||||
return value;
|
||||
|
||||
Reference in New Issue
Block a user