(source, route)
| 372 | } |
| 373 | |
| 374 | function findRouteArray(source, route) { |
| 375 | const routePattern = new RegExp(`(["'])${escapeRegExp(route)}\\1\\s*:\\s*\\[`); |
| 376 | const match = routePattern.exec(source); |
| 377 | if (!match) { |
| 378 | return null; |
| 379 | } |
| 380 | |
| 381 | const arrayStart = match.index + match[0].lastIndexOf("["); |
| 382 | const arrayEnd = findMatchingBracket(source, arrayStart); |
| 383 | if (arrayEnd === -1) { |
| 384 | throw new Error(`Could not parse route array: ${route}`); |
| 385 | } |
| 386 | return { start: arrayStart, end: arrayEnd }; |
| 387 | } |
| 388 | |
| 389 | function findMatchingBracket(source, openIndex) { |
| 390 | let depth = 0; |
no test coverage detected