MCPcopy Index your code
hub / github.com/simstudioai/sim / formatLabelToken

Function formatLabelToken

apps/sim/connectors/gmail/gmail.ts:52–60  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

50 * unquoted label tokens have spaces replaced with hyphens.
51 */
52function 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.

Callers 1

buildSearchQueryFunction · 0.85

Calls 2

testMethod · 0.80
replaceMethod · 0.65

Tested by

no test coverage detected