feat: more phase 1 implementation - proper parity now

This commit is contained in:
2026-02-22 22:39:26 +01:00
parent 3ec8819d6d
commit 7cb47e0aa5
13 changed files with 694 additions and 56 deletions

View File

@@ -94,7 +94,11 @@ export class ScriptEngine extends EventEmitter {
}
const allScripts = await this.getAllScriptRows();
const desiredSlug = this.normalizeSlug(updates.slug || updates.title || existing.slug);
const desiredSlug = typeof updates.slug === 'string'
? this.normalizeSlug(updates.slug)
: typeof updates.title === 'string'
? this.normalizeSlug(updates.title)
: existing.slug;
const nextSlug = this.ensureUniqueSlug(desiredSlug, allScripts, existing.id);
const nextFilePath = this.getScriptFilePath(nextSlug);
const now = new Date();
@@ -228,8 +232,8 @@ export class ScriptEngine extends EventEmitter {
private normalizeSlug(value: string): string {
const normalized = value
.toLowerCase()
.replace(/[^a-z0-9]+/g, '-')
.replace(/^-|-$/g, '');
.replace(/[^a-z0-9]+/g, '_')
.replace(/^_+|_+$/g, '');
return normalized || 'script';
}
@@ -246,11 +250,11 @@ export class ScriptEngine extends EventEmitter {
}
let suffix = 2;
while (taken.has(`${baseSlug}-${suffix}`)) {
while (taken.has(`${baseSlug}_${suffix}`)) {
suffix += 1;
}
return `${baseSlug}-${suffix}`;
return `${baseSlug}_${suffix}`;
}
}