* Formats a single Gmail label name for use in a `label:` operator. * Gmail search syntax accepts quoted strings for labels containing spaces; * unquoted label tokens have spaces replaced with hyphens.
(name: string)
| 50 | * unquoted label tokens have spaces replaced with hyphens. |
| 51 | */ |
| 52 | function formatLabelToken(name: string): string { |
| 53 | const trimmed = name.trim() |
| 54 | if (!trimmed) return '' |
| 55 | if (/\s/.test(trimmed)) { |
| 56 | const escaped = trimmed.replace(/\\/g, '\\\\').replace(/"/g, '\\"') |
| 57 | return `label:"${escaped}"` |
| 58 | } |
| 59 | return `label:${trimmed}` |
| 60 | } |
| 61 | |
| 62 | /** |
| 63 | * Builds a Gmail search query string from the source config. |
no test coverage detected