forked from defunkt/toes
Allow dots in app and repo names
This commit is contained in:
parent
c2264c42fc
commit
e7dd220106
|
|
@ -13,7 +13,7 @@ const DATA_ROOT = process.env.DATA_ROOT!
|
||||||
const TOES_URL = process.env.TOES_URL!
|
const TOES_URL = process.env.TOES_URL!
|
||||||
|
|
||||||
const REPOS_DIR = resolve(DATA_ROOT, 'repos')
|
const REPOS_DIR = resolve(DATA_ROOT, 'repos')
|
||||||
const VALID_NAME = /^[a-zA-Z0-9_-]+$/
|
const VALID_NAME = /^[a-zA-Z0-9._-]+$/
|
||||||
const VISIBILITY_PATH = join(DATA_DIR, 'visibility.json')
|
const VISIBILITY_PATH = join(DATA_DIR, 'visibility.json')
|
||||||
|
|
||||||
const TOGGLE_SCRIPT = `
|
const TOGGLE_SCRIPT = `
|
||||||
|
|
|
||||||
|
|
@ -20,8 +20,8 @@ async function createNewApp() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!/^[a-z][a-z0-9-]*$/.test(name)) {
|
if (!/^[a-z][a-z0-9.-]*$/.test(name)) {
|
||||||
newAppError = 'Name must start with a letter and contain only lowercase letters, numbers, and hyphens'
|
newAppError = 'Name must start with a letter and contain only lowercase letters, numbers, dots, and hyphens'
|
||||||
renderModal()
|
renderModal()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,8 +19,8 @@ async function doRenameApp(input: HTMLInputElement) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!/^[a-z][a-z0-9-]*$/.test(newName)) {
|
if (!/^[a-z][a-z0-9.-]*$/.test(newName)) {
|
||||||
renameAppError = 'Name must start with a letter and contain only lowercase letters, numbers, and hyphens'
|
renameAppError = 'Name must start with a letter and contain only lowercase letters, numbers, dots, and hyphens'
|
||||||
renderModal()
|
renderModal()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -120,8 +120,8 @@ router.post('/', async c => {
|
||||||
const name = body.name?.trim().toLowerCase().replace(/\s+/g, '-')
|
const name = body.name?.trim().toLowerCase().replace(/\s+/g, '-')
|
||||||
if (!name) return c.json({ ok: false, error: 'App name is required' }, 400)
|
if (!name) return c.json({ ok: false, error: 'App name is required' }, 400)
|
||||||
|
|
||||||
if (!/^[a-z][a-z0-9-]*$/.test(name)) {
|
if (!/^[a-z][a-z0-9.-]*$/.test(name)) {
|
||||||
return c.json({ ok: false, error: 'Name must start with a letter and contain only lowercase letters, numbers, and hyphens' }, 400)
|
return c.json({ ok: false, error: 'Name must start with a letter and contain only lowercase letters, numbers, dots, and hyphens' }, 400)
|
||||||
}
|
}
|
||||||
|
|
||||||
const appPath = join(APPS_DIR, name)
|
const appPath = join(APPS_DIR, name)
|
||||||
|
|
|
||||||
|
|
@ -176,8 +176,8 @@ export async function renameApp(oldName: string, newName: string): Promise<{ ok:
|
||||||
|
|
||||||
if (_apps.has(newName)) return { ok: false, error: 'An app with that name already exists' }
|
if (_apps.has(newName)) return { ok: false, error: 'An app with that name already exists' }
|
||||||
|
|
||||||
if (!/^[a-z][a-z0-9-]*$/.test(newName)) {
|
if (!/^[a-z][a-z0-9.-]*$/.test(newName)) {
|
||||||
return { ok: false, error: 'Name must start with a letter and contain only lowercase letters, numbers, and hyphens' }
|
return { ok: false, error: 'Name must start with a letter and contain only lowercase letters, numbers, dots, and hyphens' }
|
||||||
}
|
}
|
||||||
|
|
||||||
const oldPath = join(APPS_DIR, oldName)
|
const oldPath = join(APPS_DIR, oldName)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user