@@ -2017,9 +2017,6 @@ export class Stack {
2017
2017
2018
2018
private async bindLeftoverAssets ( queries : IQuery , locale : string , pointerList : IShelf [ ] ) {
2019
2019
// const contents = await readFile(getAssetsPath(locale) + '.json')
2020
- if ( ! this . sanitizeIQuery ( queries ) ) {
2021
- throw new Error ( 'Invalid queries provided' ) ;
2022
- }
2023
2020
const filteredAssets = await this . db . collection ( getCollectionName ( {
2024
2021
content_type_uid : this . types . assets ,
2025
2022
locale,
@@ -2099,9 +2096,6 @@ export class Stack {
2099
2096
}
2100
2097
2101
2098
private async getReferencePath ( query , locale , currentInclude ) {
2102
- if ( ! this . sanityQueryAny ( query ) ) {
2103
- throw new Error ( 'Invalid query provided' ) ;
2104
- }
2105
2099
const schemas = await this . db . collection ( getCollectionName ( {
2106
2100
content_type_uid : this . types . content_types ,
2107
2101
locale,
@@ -2190,9 +2184,6 @@ export class Stack {
2190
2184
2191
2185
private async fetchEntries ( query : IQuery , locale : string , paths : string [ ] , include : string [ ] , includeAll :
2192
2186
boolean = false ) {
2193
- if ( ! this . sanitizeIQuery ( query ) ) {
2194
- throw new Error ( 'Invalid queries provided' ) ;
2195
- }
2196
2187
const result = await this . db . collection ( getCollectionName ( {
2197
2188
content_type_uid : 'entries' ,
2198
2189
locale,
@@ -2385,30 +2376,5 @@ export class Stack {
2385
2376
paths,
2386
2377
}
2387
2378
}
2388
-
2389
- private sanitizeIQuery ( query : IQuery ) : boolean {
2390
- if ( ! query || typeof query !== 'object' || Array . isArray ( query ) ) {
2391
- return false ;
2392
- }
2393
- if ( ! query || ! Array . isArray ( query . $or ) ) {
2394
- return false ;
2395
- }
2396
- for ( const item of query . $or ) {
2397
- if (
2398
- typeof item . _content_type_uid !== 'string' ||
2399
- typeof item . uid !== 'string' ||
2400
- ( item . _version && typeof item . _version . $exists !== 'boolean' ) ||
2401
- ( item . locale && typeof item . locale !== 'string' )
2402
- ) {
2403
- return false ;
2404
- }
2405
- }
2406
- return true ;
2407
- }
2408
- private sanityQueryAny ( query : any ) : boolean {
2409
- if ( ! query || typeof query !== 'object' || Array . isArray ( query ) ) {
2410
- return false ;
2411
- }
2412
- return true ;
2413
- }
2379
+ // tslint:disable-next-line: max-file-line-count
2414
2380
}
0 commit comments