@@ -136,15 +136,14 @@ async function globHandler (req, res, next) {
136
136
// TODO: This is a hack, that does not check if the target file exists, as this is quite complex with globbing.
137
137
// TODO: Proper support for this is not implemented, as globbing support might be removed in the future.
138
138
const filename = ldp . resourceMapper . getFilePath ( req )
139
- const requestUri = ( await ldp . resourceMapper . mapFileToUrl ( { path : filename , hostname : req . hostname } ) ) . url
140
139
141
140
const globOptions = {
142
141
noext : true ,
143
142
nobrace : true ,
144
143
nodir : true
145
144
}
146
145
147
- glob ( filename , globOptions , function ( err , matches ) {
146
+ glob ( filename , globOptions , async ( err , matches ) => {
148
147
if ( err || matches . length === 0 ) {
149
148
debugGlob ( 'No files matching the pattern' )
150
149
return next ( error ( 404 , 'No files matching glob pattern' ) )
@@ -154,7 +153,7 @@ async function globHandler (req, res, next) {
154
153
const globGraph = $rdf . graph ( )
155
154
156
155
debugGlob ( 'found matches ' + matches )
157
- Promise . all ( matches . map ( match => new Promise ( async ( resolve , reject ) => {
156
+ await Promise . all ( matches . map ( match => new Promise ( async ( resolve , reject ) => {
158
157
const urlData = await ldp . resourceMapper . mapFileToUrl ( { path : match , hostname : req . hostname } )
159
158
fs . readFile ( match , { encoding : 'utf8' } , function ( err , fileData ) {
160
159
if ( err ) {
@@ -178,15 +177,15 @@ async function globHandler (req, res, next) {
178
177
} )
179
178
} )
180
179
} ) ) )
181
- . then ( ( ) => {
182
- const data = $rdf . serialize ( undefined , globGraph , requestUri , 'text/turtle' )
183
- // TODO this should be added as a middleware in the routes
184
- res . setHeader ( 'Content-Type' , 'text/turtle' )
185
- debugGlob ( 'returning turtle')
186
-
187
- res . send ( data )
188
- return next ( )
189
- } )
180
+
181
+ const requestUri = await ldp . resourceMapper . getPublicUrl ( req )
182
+ const data = $rdf . serialize ( undefined , globGraph , requestUri , 'text/turtle' )
183
+ // TODO this should be added as a middleware in the routes
184
+ res . setHeader ( 'Content-Type' , 'text/ turtle')
185
+ debugGlob ( 'returning turtle' )
186
+
187
+ res . send ( data )
188
+ next ( )
190
189
} )
191
190
}
192
191
0 commit comments