Skip to content

Commit bf760f9

Browse files
committed
update more dependencies
1 parent f18e73e commit bf760f9

File tree

3 files changed

+334
-310
lines changed

3 files changed

+334
-310
lines changed

lib/handlers/get.mjs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import { createRequire } from 'module'
44
import fs from 'fs'
5-
import glob from 'glob'
5+
import { glob, hasMagic } from 'glob'
66
import _path from 'path'
77
import $rdf from 'rdflib'
88
import Negotiator from 'negotiator'
@@ -37,7 +37,7 @@ export default async function handler (req, res, next) {
3737

3838
res.header('Accept-Patch', 'text/n3, application/sparql-update, application/sparql-update-single-match')
3939
res.header('Accept-Post', '*/*')
40-
if (!path.endsWith('/') && !glob.hasMagic(path)) res.header('Accept-Put', '*/*')
40+
if (!path.endsWith('/') && !hasMagic(path)) res.header('Accept-Put', '*/*')
4141

4242
// Set live updates
4343
if (ldp.live) {
@@ -62,7 +62,7 @@ export default async function handler (req, res, next) {
6262
// set Accept-Put if container do not exist
6363
if (err.status === 404 && path.endsWith('/')) res.header('Accept-Put', 'text/turtle')
6464
// use globHandler if magic is detected
65-
if (err.status === 404 && glob.hasMagic(path)) {
65+
if (err.status === 404 && hasMagic(path)) {
6666
debug('forwarding to glob request')
6767
return globHandler(req, res, next)
6868
} else {
@@ -188,8 +188,9 @@ async function globHandler (req, res, next) {
188188
nodir: true
189189
}
190190

191-
glob(`${folderPath}*`, globOptions, async (err, matches) => {
192-
if (err || matches.length === 0) {
191+
try {
192+
const matches = await glob(`${folderPath}*`, globOptions)
193+
if (matches.length === 0) {
193194
debugGlob('No files matching the pattern')
194195
return next(HTTPError(404, 'No files matching glob pattern'))
195196
}
@@ -230,7 +231,10 @@ async function globHandler (req, res, next) {
230231

231232
res.send(data)
232233
next()
233-
})
234+
} catch (err) {
235+
debugGlob('Error during glob: ' + err)
236+
return next(HTTPError(500, 'Error processing glob pattern'))
237+
}
234238
}
235239

236240
// TODO: get rid of this ugly hack that uses the Allow handler to check read permissions

0 commit comments

Comments
 (0)