2024-02-15 04:48:48 -05:00
|
|
|
import { Minimatch } from 'minimatch'
|
2024-06-18 06:01:37 -04:00
|
|
|
import getMeta from '@/utils/meta'
|
2024-02-15 04:48:48 -05:00
|
|
|
|
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(
|
2024-06-18 06:01:37 -04:00
|
|
|
getMeta('ol-ExposedSettings').fileIgnorePattern,
|
2024-05-21 07:34:34 -04:00
|
|
|
{ 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)
|
|
|
|
}
|