* Check if ID looks like a GUID (from selectorGenerator.ts lines 479-506)
(id)
| 376 | * Check if ID looks like a GUID (from selectorGenerator.ts lines 479-506) |
| 377 | */ |
| 378 | function isGuidLike(id) { |
| 379 | let lastCharacterType; |
| 380 | let transitionCount = 0; |
| 381 | for (let i = 0; i < id.length; ++i) { |
| 382 | const c = id[i]; |
| 383 | let characterType; |
| 384 | if (c === '-' || c === '_') |
| 385 | continue; |
| 386 | if (c >= 'a' && c <= 'z') |
| 387 | characterType = 'lower'; |
| 388 | else if (c >= 'A' && c <= 'Z') |
| 389 | characterType = 'upper'; |
| 390 | else if (c >= '0' && c <= '9') |
| 391 | characterType = 'digit'; |
| 392 | else |
| 393 | characterType = 'other'; |
| 394 | |
| 395 | if (characterType === 'lower' && lastCharacterType === 'upper') { |
| 396 | lastCharacterType = characterType; |
| 397 | continue; |
| 398 | } |
| 399 | |
| 400 | if (lastCharacterType && lastCharacterType !== characterType) |
| 401 | ++transitionCount; |
| 402 | lastCharacterType = characterType; |
| 403 | } |
| 404 | return transitionCount >= id.length / 4; |
| 405 | } |
| 406 | |
| 407 | /** |
| 408 | * Build selector candidates (ported from buildNoTextCandidates and buildTextCandidates) |