Function
parseDebug
(debug: string | Array<string> | undefined)
Source from the content-addressed store, hash-verified
| 20 | } |
| 21 | |
| 22 | function parseDebug(debug: string | Array<string> | undefined) { |
| 23 | if (debug === '') { |
| 24 | // E.g. `?query=foo&debug` should be treated as truthy |
| 25 | return true |
| 26 | } |
| 27 | |
| 28 | if (!debug) { |
| 29 | return false |
| 30 | } |
| 31 | |
| 32 | // Now `router.query.debug` is either string or any array of strings |
| 33 | if (Array.isArray(debug)) { |
| 34 | debug = debug[0] |
| 35 | } |
| 36 | |
| 37 | try { |
| 38 | debug = JSON.parse(debug) |
| 39 | return Boolean(debug) |
| 40 | } catch (e) {} |
| 41 | |
| 42 | return false |
| 43 | } |
Tested by
no test coverage detected