MCPcopy Create free account
hub / github.com/formkit/formkit / isQuotedString

Function isQuotedString

packages/utils/src/index.ts:395–410  ·  view source on GitHub ↗
(str: string)

Source from the content-addressed store, hash-verified

393 * @public
394 */
395export function isQuotedString(str: string): boolean {
396 // quickly return false if the value is note quoted
397 if (str[0] !== '"' && str[0] !== "'") return false
398 if (str[0] !== str[str.length - 1]) return false
399 const quoteType = str[0]
400 for (let p = 1; p < str.length; p++) {
401 if (
402 str[p] === quoteType &&
403 (p === 1 || str[p - 1] !== '\\') &&
404 p !== str.length - 1
405 ) {
406 return false
407 }
408 }
409 return true
410}
411
412/**
413 * Remove extra escape characters.

Callers 2

utils.spec.tsFile · 0.90
evaluateFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected