File tree 1 file changed +11
-6
lines changed
1 file changed +11
-6
lines changed Original file line number Diff line number Diff line change @@ -150,14 +150,19 @@ export class HttpApi {
150
150
return res . status ( 400 ) . send ( 'protocol path is required' ) ;
151
151
}
152
152
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 , '' ) ;
155
163
156
164
const query = await RecordsQuery . create ( {
157
- filter : {
158
- protocol,
159
- protocolPath,
160
- } ,
165
+ filter : queryOptions . filter ,
161
166
pagination : { limit : 1 } ,
162
167
dateSort : DateSort . PublishedDescending
163
168
} ) ;
You can’t perform that action at this time.
0 commit comments