Skip to content

Commit 1b86631

Browse files
added missing snippets
1 parent e980c49 commit 1b86631

File tree

2 files changed

+1
-37
lines changed

2 files changed

+1
-37
lines changed

src/stack.ts

Lines changed: 1 addition & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2017,9 +2017,6 @@ export class Stack {
20172017

20182018
private async bindLeftoverAssets(queries: IQuery, locale: string, pointerList: IShelf[]) {
20192019
// const contents = await readFile(getAssetsPath(locale) + '.json')
2020-
if (!this.sanitizeIQuery(queries)) {
2021-
throw new Error('Invalid queries provided');
2022-
}
20232020
const filteredAssets = await this.db.collection(getCollectionName({
20242021
content_type_uid: this.types.assets,
20252022
locale,
@@ -2099,9 +2096,6 @@ export class Stack {
20992096
}
21002097

21012098
private async getReferencePath(query, locale, currentInclude) {
2102-
if (!this.sanityQueryAny(query)) {
2103-
throw new Error('Invalid query provided');
2104-
}
21052099
const schemas = await this.db.collection(getCollectionName({
21062100
content_type_uid: this.types.content_types,
21072101
locale,
@@ -2190,9 +2184,6 @@ export class Stack {
21902184

21912185
private async fetchEntries(query: IQuery, locale: string, paths: string[], include: string[], includeAll:
21922186
boolean = false) {
2193-
if (!this.sanitizeIQuery(query)) {
2194-
throw new Error('Invalid queries provided');
2195-
}
21962187
const result = await this.db.collection(getCollectionName({
21972188
content_type_uid: 'entries',
21982189
locale,
@@ -2385,30 +2376,5 @@ export class Stack {
23852376
paths,
23862377
}
23872378
}
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
24142380
}

typings/stack.d.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1092,6 +1092,4 @@ export declare class Stack {
10921092
private bindReferences;
10931093
private includeAllReferencesIteration;
10941094
private getAllReferencePaths;
1095-
private sanitizeIQuery;
1096-
private sanityQueryAny;
10971095
}

0 commit comments

Comments
 (0)