MCPcopy Create free account
hub / github.com/F12FLASH/CTF / calculateQueryDepth

Function calculateQueryDepth

7.GraphQL Apocalypse/server/routes.ts:26–51  ·  view source on GitHub ↗
(query: string)

Source from the content-addressed store, hash-verified

24}
25
26function calculateQueryDepth(query: string): number {
27 let depth = 0;
28 let currentDepth = 0;
29 let inString = false;
30
31 for (let i = 0; i < query.length; i++) {
32 const char = query[i];
33
34 if (char === '"' && query[i - 1] !== '\\') {
35 inString = !inString;
36 }
37
38 if (!inString) {
39 if (char === '{') {
40 currentDepth++;
41 if (currentDepth > depth) {
42 depth = currentDepth;
43 }
44 } else if (char === '}') {
45 currentDepth--;
46 }
47 }
48 }
49
50 return depth;
51}
52
53export async function registerRoutes(app: Express): Promise<Server> {
54 app.use(

Callers 1

registerRoutesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected