Open speker2010 opened 2 years ago
I have the same issue. Parentheses are incorrectly considered invalid.
I quickly wrote this function to test paths. I guess it can be better, but it is just a quick fix to solve this problem in our code
export function isValidPath(pathName: string) {
try {
const resolvedPath = resolve(pathName)
if (resolvedPath) {
if (process.platform === 'win32') {
if (pathName.length > 4 && pathName[2] === '?' && pathName[0] === '\\' && pathName[1] === '\\' && pathName[3] === '\\') { pathName = pathName.substring(4) }
if (pathName.length > 2 && pathName[1] === ':' && pathName[2] === '\\') { pathName = pathName.substring(2) }
return !/[<>:"|?*]/.test(pathName)
}
return true
}
}
catch(_e: unknown) {
}
return false
}
There is should be something like this 'images/my-photo(1).jpg', isn't it? https://github.com/jonschlinkert/is-valid-path/blob/master/test.js#L15-L20
I think it's correct filename