mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 05:31:23 +00:00
chore: Enable "curly" rule to avoid single-statement if confusion/errors.
This commit is contained in:
@@ -106,7 +106,9 @@ function randomChoice(values: string[], fallback: string) {
|
||||
|
||||
function createSlugBase(words = 2) {
|
||||
const parts = [randomChoice(SLUG_ADJECTIVES, "steady"), randomChoice(SLUG_NOUNS, "harbor")];
|
||||
if (words > 2) parts.push(randomChoice(SLUG_NOUNS, "reef"));
|
||||
if (words > 2) {
|
||||
parts.push(randomChoice(SLUG_NOUNS, "reef"));
|
||||
}
|
||||
return parts.join("-");
|
||||
}
|
||||
|
||||
@@ -114,18 +116,26 @@ export function createSessionSlug(isTaken?: (id: string) => boolean): string {
|
||||
const isIdTaken = isTaken ?? (() => false);
|
||||
for (let attempt = 0; attempt < 12; attempt += 1) {
|
||||
const base = createSlugBase(2);
|
||||
if (!isIdTaken(base)) return base;
|
||||
if (!isIdTaken(base)) {
|
||||
return base;
|
||||
}
|
||||
for (let i = 2; i <= 12; i += 1) {
|
||||
const candidate = `${base}-${i}`;
|
||||
if (!isIdTaken(candidate)) return candidate;
|
||||
if (!isIdTaken(candidate)) {
|
||||
return candidate;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (let attempt = 0; attempt < 12; attempt += 1) {
|
||||
const base = createSlugBase(3);
|
||||
if (!isIdTaken(base)) return base;
|
||||
if (!isIdTaken(base)) {
|
||||
return base;
|
||||
}
|
||||
for (let i = 2; i <= 12; i += 1) {
|
||||
const candidate = `${base}-${i}`;
|
||||
if (!isIdTaken(candidate)) return candidate;
|
||||
if (!isIdTaken(candidate)) {
|
||||
return candidate;
|
||||
}
|
||||
}
|
||||
}
|
||||
const fallback = `${createSlugBase(3)}-${Math.random().toString(36).slice(2, 5)}`;
|
||||
|
||||
Reference in New Issue
Block a user