( parameters: Record<string, any>, key: string, allowObjects: boolean = false, )
| 150 | } |
| 151 | |
| 152 | export function getParam( |
| 153 | parameters: Record<string, any>, |
| 154 | key: string, |
| 155 | allowObjects: boolean = false, |
| 156 | ): any { |
| 157 | let out: any = undefined; |
| 158 | if (key in parameters) out = parameters[key]; |
| 159 | if (!out) { |
| 160 | // Sometimes (rarely) the AI replaces hyphens with underscores. This is a hacky fix |
| 161 | const found = Object.keys(parameters).find( |
| 162 | (k) => k.replace(/-/g, "_") === key.replace(/-/g, "_"), |
| 163 | ); |
| 164 | if (found) out = parameters[found]; |
| 165 | } |
| 166 | if (out === undefined) return undefined; |
| 167 | if (allowObjects && typeof out === "object") { |
| 168 | return JSON.stringify(out); |
| 169 | } |
| 170 | return out; |
| 171 | } |
| 172 | |
| 173 | export function parseErrorHtml(str: string): string { |
| 174 | const elements = []; |
no outgoing calls
no test coverage detected