@ditojs/server 1.5.0 → 1.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ditojs/server",
3
- "version": "1.5.0",
3
+ "version": "1.5.1",
4
4
  "type": "module",
5
5
  "description": "Dito.js Server – Dito.js is a declarative and modern web framework, based on Objection.js, Koa.js and Vue.js",
6
6
  "repository": "https://github.com/ditojs/dito/tree/master/packages/server",
@@ -60,6 +60,7 @@
60
60
  "passport-local": "^1.0.0",
61
61
  "passthrough-counter": "^1.0.0",
62
62
  "picocolors": "^1.0.0",
63
+ "picomatch": "^2.3.1",
63
64
  "pino": "^7.9.2",
64
65
  "pino-pretty": "^7.6.0",
65
66
  "pluralize": "^8.0.0",
@@ -80,5 +81,5 @@
80
81
  "pg": "^8.7.3",
81
82
  "sqlite3": "^5.0.2"
82
83
  },
83
- "gitHead": "36a57512228cc233211bf6e4038123a9e775f5c5"
84
+ "gitHead": "40731960cf8b528f4f40f8b7e43e2e966138337c"
84
85
  }
@@ -1,11 +1,11 @@
1
1
  import path from 'path'
2
+ import { URL } from 'url'
2
3
  import multer from '@koa/multer'
4
+ import picomatch from 'picomatch'
3
5
  import imageSize from 'image-size'
4
6
  import { PassThrough } from 'stream'
5
- import { URL } from 'url'
6
7
  import { hyphenate, toPromiseCallback } from '@ditojs/utils'
7
8
  import { AssetFile } from './AssetFile.js'
8
- import { matchGlobPattern } from '../utils/glob.js'
9
9
 
10
10
  const storageClasses = {}
11
11
 
@@ -59,11 +59,7 @@ export class Storage {
59
59
  }
60
60
 
61
61
  isImportSourceAllowed(url) {
62
- const { allowedImports = [] } = this.config
63
- for (const pattern of allowedImports) {
64
- if (matchGlobPattern(url, pattern)) return true
65
- }
66
- return false
62
+ return picomatch.isMatch(url, this.config.allowedImports || [])
67
63
  }
68
64
 
69
65
  convertAssetFile(file) {
package/src/utils/glob.js DELETED
@@ -1,9 +0,0 @@
1
- import { escapeRegexp } from '@ditojs/utils'
2
-
3
- export function matchGlobPattern(str, pattern) {
4
- const exp = escapeRegexp(pattern).replace(
5
- /\\([*?])/,
6
- (_, chr) => chr === '*' ? '.*' : chr
7
- )
8
- return new RegExp(`^${exp}$`).test(str)
9
- }