(stored: unknown)
| 242 | |
| 243 | /** Decode a stored FILE variable value into its representation kind. */ |
| 244 | export function decodeFileValue(stored: unknown): DecodedFileValue { |
| 245 | if (typeof stored !== "string" || stored === "") return { kind: "empty" }; |
| 246 | if (stored.startsWith(FILE_CUSTOM_PREFIX)) |
| 247 | return { kind: "custom", text: stored.slice(FILE_CUSTOM_PREFIX.length) }; |
| 248 | if (stored.startsWith(FILE_PICK_PREFIX)) |
| 249 | return { kind: "file", path: stored.slice(FILE_PICK_PREFIX.length) }; |
| 250 | return { kind: "raw", value: stored }; |
| 251 | } |
| 252 | |
| 253 | /** Basename of a vault path (drop folders + a trailing known extension). */ |
| 254 | export function fileBasenameFromPath(value: string): string { |
no outgoing calls
no test coverage detected