is-acceptable-file.ts 660 B

1234567891011121314151617181920212223242526
  1. import { Minimatch } from 'minimatch'
  2. import getMeta from '@/utils/meta'
  3. let fileIgnoreMatcher: Minimatch
  4. export const isAcceptableFile = (name?: string, relativePath?: string) => {
  5. if (!fileIgnoreMatcher) {
  6. fileIgnoreMatcher = new Minimatch(
  7. getMeta('ol-ExposedSettings').fileIgnorePattern,
  8. { nocase: true, dot: true }
  9. )
  10. }
  11. if (!name) {
  12. // the file must have a name, of course
  13. return false
  14. }
  15. if (!relativePath) {
  16. // uploading an individual file, so allow anything
  17. return true
  18. }
  19. // uploading a file in a folder, so exclude unwanted file paths
  20. return !fileIgnoreMatcher.match(relativePath + '/' + name)
  21. }