MCPcopy Create free account
hub / github.com/ZenNotes/zennotes / customThemeRevealTarget

Function customThemeRevealTarget

apps/desktop/src/main/custom-themes.ts:410–420  ·  view source on GitHub ↗
(slug?: string)

Source from the content-addressed store, hash-verified

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. */
410export 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). */

Callers 2

registerIpcFunction · 0.90

Calls 2

ensureCustomThemesDirFunction · 0.85
isSafeSlugFunction · 0.85

Tested by

no test coverage detected