mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
3cb4190ef0
[web] initialize matcher for ignored file paths lazily GitOrigin-RevId: ed04b286e188ad73e3090822965b19ccf2e7d2b4
25 lines
618 B
TypeScript
25 lines
618 B
TypeScript
import { Minimatch } from 'minimatch'
|
|
|
|
let fileIgnoreMatcher: Minimatch
|
|
|
|
export const isAcceptableFile = (name?: string, relativePath?: string) => {
|
|
if (!fileIgnoreMatcher) {
|
|
fileIgnoreMatcher = new Minimatch(
|
|
window.ExposedSettings.fileIgnorePattern,
|
|
{ nocase: true, dot: true }
|
|
)
|
|
}
|
|
|
|
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)
|
|
}
|