mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-11 03:34:33 +00:00
chore: Enable "curly" rule to avoid single-statement if confusion/errors.
This commit is contained in:
@@ -6,8 +6,12 @@ export type NormalizedAllowFrom = {
|
||||
|
||||
function normalizeAllowEntry(value: string | number): string {
|
||||
const trimmed = String(value).trim();
|
||||
if (!trimmed) return "";
|
||||
if (trimmed === "*") return "*";
|
||||
if (!trimmed) {
|
||||
return "";
|
||||
}
|
||||
if (trimmed === "*") {
|
||||
return "*";
|
||||
}
|
||||
return trimmed.replace(/^line:(?:user:)?/i, "");
|
||||
}
|
||||
|
||||
@@ -31,7 +35,9 @@ export const normalizeAllowFromWithStore = (params: {
|
||||
|
||||
export const firstDefined = <T>(...values: Array<T | undefined>) => {
|
||||
for (const value of values) {
|
||||
if (typeof value !== "undefined") return value;
|
||||
if (typeof value !== "undefined") {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
};
|
||||
@@ -41,8 +47,14 @@ export const isSenderAllowed = (params: {
|
||||
senderId?: string;
|
||||
}): boolean => {
|
||||
const { allow, senderId } = params;
|
||||
if (!allow.hasEntries) return false;
|
||||
if (allow.hasWildcard) return true;
|
||||
if (!senderId) return false;
|
||||
if (!allow.hasEntries) {
|
||||
return false;
|
||||
}
|
||||
if (allow.hasWildcard) {
|
||||
return true;
|
||||
}
|
||||
if (!senderId) {
|
||||
return false;
|
||||
}
|
||||
return allow.entries.includes(senderId);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user