( ioInfo: ReactIOInfo, description: string, env: void | string, rootEnv: string, )
| 317 | } |
| 318 | |
| 319 | function getIOShortName( |
| 320 | ioInfo: ReactIOInfo, |
| 321 | description: string, |
| 322 | env: void | string, |
| 323 | rootEnv: string, |
| 324 | ): string { |
| 325 | const name = ioInfo.name; |
| 326 | const isPrimaryEnv = env === rootEnv; |
| 327 | const envSuffix = isPrimaryEnv || env === undefined ? '' : ' [' + env + ']'; |
| 328 | let desc = ''; |
| 329 | const descMaxLength = 30 - name.length - envSuffix.length; |
| 330 | if (descMaxLength > 1) { |
| 331 | const l = description.length; |
| 332 | if (l > 0 && l <= descMaxLength) { |
| 333 | // We can fit the full description |
| 334 | desc = ' (' + description + ')'; |
| 335 | } else if ( |
| 336 | description.startsWith('http://') || |
| 337 | description.startsWith('https://') || |
| 338 | description.startsWith('/') |
| 339 | ) { |
| 340 | // Looks like a URL. Let's see if we can extract something shorter. |
| 341 | // We don't have to do a full parse so let's try something cheaper. |
| 342 | let queryIdx = description.indexOf('?'); |
| 343 | if (queryIdx === -1) { |
| 344 | queryIdx = description.length; |
| 345 | } |
| 346 | if (description.charCodeAt(queryIdx - 1) === 47 /* "/" */) { |
| 347 | // Ends with slash. Look before that. |
| 348 | queryIdx--; |
| 349 | } |
| 350 | const slashIdx = description.lastIndexOf('/', queryIdx - 1); |
| 351 | if (queryIdx - slashIdx < descMaxLength) { |
| 352 | // This may now be either the file name or the host. |
| 353 | // Include the slash to make it more obvious what we trimmed. |
| 354 | desc = ' (…' + description.slice(slashIdx, queryIdx) + ')'; |
| 355 | } else { |
| 356 | // cut out the middle to not exceed the max length |
| 357 | const start = description.slice(slashIdx, slashIdx + descMaxLength / 2); |
| 358 | const end = description.slice(queryIdx - descMaxLength / 2, queryIdx); |
| 359 | desc = ' (' + (slashIdx > 0 ? '…' : '') + start + '…' + end + ')'; |
| 360 | } |
| 361 | } |
| 362 | } |
| 363 | return name + desc + envSuffix; |
| 364 | } |
| 365 | |
| 366 | export function logComponentAwaitAborted( |
| 367 | asyncInfo: ReactAsyncInfo, |
no outgoing calls
no test coverage detected