(filename: string)
| 60 | * runs of invalid characters into a single underscore. |
| 61 | */ |
| 62 | export 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 |
no test coverage detected