(method: unknown)
| 167 | const methodTokenRegExp = /^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/ |
| 168 | |
| 169 | const normalizeIncomingMethod = (method: unknown): string => { |
| 170 | if (typeof method !== 'string' || method.length === 0) { |
| 171 | return 'GET' |
| 172 | } |
| 173 | |
| 174 | // fast path for already-uppercase common methods from Node.js. |
| 175 | switch (method) { |
| 176 | case 'DELETE': |
| 177 | case 'GET': |
| 178 | case 'HEAD': |
| 179 | case 'OPTIONS': |
| 180 | case 'POST': |
| 181 | case 'PUT': |
| 182 | return method |
| 183 | } |
| 184 | |
| 185 | const upper = method.toUpperCase() |
| 186 | switch (upper) { |
| 187 | case 'DELETE': |
| 188 | case 'GET': |
| 189 | case 'HEAD': |
| 190 | case 'OPTIONS': |
| 191 | case 'POST': |
| 192 | case 'PUT': |
| 193 | return upper |
| 194 | default: |
| 195 | return method |
| 196 | } |
| 197 | } |
| 198 | |
| 199 | const validateDirectReadMethod = (method: string): TypeError | undefined => { |
| 200 | if (!methodTokenRegExp.test(method)) { |
no outgoing calls
no test coverage detected
searching dependent graphs…