MCPcopy Create free account
hub / github.com/block/buzz / suggestShortcodeFromFilename

Function suggestShortcodeFromFilename

desktop/src/shared/api/customEmoji.ts:62–73  ·  view source on GitHub ↗
(filename: string)

Source from the content-addressed store, hash-verified

60 * runs of invalid characters into a single underscore.
61 */
62export function suggestShortcodeFromFilename(filename: string): string | null {
63 const basename = filename
64 .trim()
65 .replace(/^.*[/\\]/, "")
66 .replace(/\.[^.]*$/, "");
67 const suggested = basename
68 .toLowerCase()
69 .replace(/[^a-z0-9_-]+/g, "_")
70 .replace(/_+/g, "_")
71 .replace(/^[_-]+|[_-]+$/g, "");
72 return normalizeShortcode(suggested);
73}
74
75/**
76 * Parse NIP-30 `["emoji", shortcode, url]` tags from a single event into a

Callers 2

CustomEmojiSettingsCardFunction · 0.90

Calls 1

normalizeShortcodeFunction · 0.85

Tested by

no test coverage detected