* Convert SQL LIKE pattern to JavaScript regex * Supports % (any chars) and _ (single char)
(pattern: string)
| 58 | * Supports % (any chars) and _ (single char) |
| 59 | */ |
| 60 | function likePatternToRegex(pattern: string): RegExp { |
| 61 | // Escape special regex characters except % and _ |
| 62 | const escaped = pattern |
| 63 | .replace(/[.*+?^${}()|[\]\\]/g, "\\$&") |
| 64 | .replace(/%/g, ".*") |
| 65 | .replace(/_/g, "."); |
| 66 | |
| 67 | return new RegExp(`^${escaped}$`, "i"); |
| 68 | } |
| 69 | |
| 70 | /** |
| 71 | * Resolve the set of schemas a search should scope to when the caller did not |
no outgoing calls
no test coverage detected