2024-02-15 04:48:48 -05:00
|
|
|
import { Minimatch } from 'minimatch'
|
|
|
|
|
2024-05-21 07:34:34 -04:00
|
|
|
let fileIgnoreMatcher: Minimatch
|
2024-02-15 04:48:48 -05:00
|
|
|
|
2024-02-21 06:34:25 -05:00
|
|
|
export const isAcceptableFile = (name?: string, relativePath?: string) => {
|
2024-05-21 07:34:34 -04:00
|
|
|
if (!fileIgnoreMatcher) {
|
|
|
|
fileIgnoreMatcher = new Minimatch(
|
|
|
|
window.ExposedSettings.fileIgnorePattern,
|
|
|
|
{ nocase: true, dot: true }
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2024-02-21 06:34:25 -05:00
|
|
|
if (!name) {
|
|
|
|
// the file must have a name, of course
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!relativePath) {
|
|
|
|
// uploading an individual file, so allow anything
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
|
|
|
// uploading a file in a folder, so exclude unwanted file paths
|
|
|
|
return !fileIgnoreMatcher.match(relativePath + '/' + name)
|
|
|
|
}
|