fix: dont use regex to extract filename

closes #12
This commit is contained in:
alina 🌸 2023-10-30 21:40:51 +03:00
parent 55b1f2a582
commit f31d93c365
Signed by: teidesu
SSH key fingerprint: SHA256:uNeCpw6aTSU4aIObXLvHfLkDa82HWH9EiOj9AXOIRpI

View file

@ -115,16 +115,13 @@ export function svgPathToFile(path: string): Uint8Array {
) )
} }
const FILENAME_REGEX = /^(?:file:)?(\/?.+[/\\])*(.+\..+)$/
/** /**
* Get file name from file path * Get file name from file path
* *
* @param path File path * @param path File path
*/ */
export function extractFileName(path: string): string { export function extractFileName(path: string): string {
const m = path.match(FILENAME_REGEX) if (path.startsWith('file:')) path = path.slice(5)
if (m) return m[2]
return '' return path.split(/[\\/]/).pop()!
} }