(slug?: string)
| 408 | /** What to reveal in the file manager: a theme's `theme.css` when the slug is |
| 409 | * valid and exists, otherwise its folder, otherwise the themes dir. */ |
| 410 | export async function customThemeRevealTarget(slug?: string): Promise<string> { |
| 411 | const dir = await ensureCustomThemesDir() |
| 412 | if (isSafeSlug(slug)) { |
| 413 | const folder = path.join(dir, slug) |
| 414 | if (path.dirname(path.resolve(folder)) === path.resolve(dir) && fsSync.existsSync(folder)) { |
| 415 | const css = path.join(folder, 'theme.css') |
| 416 | return fsSync.existsSync(css) ? css : folder |
| 417 | } |
| 418 | } |
| 419 | return dir |
| 420 | } |
| 421 | |
| 422 | /** Delete a custom theme folder. Refuses anything that isn't a bare slug |
| 423 | * resolving to a direct child of the themes dir (no path traversal). */ |
no test coverage detected