You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
19 lines
489 B
19 lines
489 B
import type { KnownConfigKey } from "./registry";
|
|
|
|
const TRIMMABLE_GLOBAL_CONFIG_KEYS = [
|
|
"siteName",
|
|
"commentMailFromEmail",
|
|
"commentSmtpHost",
|
|
"commentSmtpUser",
|
|
"commentSmtpPass",
|
|
] as const;
|
|
|
|
export function normalizeGlobalConfigValue<K extends KnownConfigKey>(key: K, value: unknown): unknown {
|
|
if (typeof value !== "string") {
|
|
return value;
|
|
}
|
|
if ((TRIMMABLE_GLOBAL_CONFIG_KEYS as readonly string[]).includes(key)) {
|
|
return value.trim();
|
|
}
|
|
return value;
|
|
}
|
|
|