File tree Expand file tree Collapse file tree 1 file changed +11
-6
lines changed
Expand file tree Collapse file tree 1 file changed +11
-6
lines changed Original file line number Diff line number Diff line change @@ -150,14 +150,19 @@ export class HttpApi {
150150 return res . status ( 400 ) . send ( 'protocol path is required' ) ;
151151 }
152152
153- const protocolPath = req . params [ 0 ] . replace ( leadTailSlashRegex , '' ) ;
154- const protocol = req . params . protocol ;
153+ const queryOptions = { filter : { } } as any ;
154+ for ( const param in req . query ) {
155+ const keys = param . split ( '.' ) ;
156+ const lastKey = keys . pop ( ) ;
157+ const lastLevelObject = keys . reduce ( ( obj , key ) => obj [ key ] = obj [ key ] || { } , queryOptions )
158+ lastLevelObject [ lastKey ] = req . query [ param ] ;
159+ }
160+
161+ queryOptions . filter . protocol = req . params . protocol ;
162+ queryOptions . filter . protocolPath = req . params [ 0 ] . replace ( leadTailSlashRegex , '' ) ;
155163
156164 const query = await RecordsQuery . create ( {
157- filter : {
158- protocol,
159- protocolPath,
160- } ,
165+ filter : queryOptions . filter ,
161166 pagination : { limit : 1 } ,
162167 dateSort : DateSort . PublishedDescending
163168 } ) ;
You can’t perform that action at this time.
0 commit comments