MCPcopy
hub / github.com/CodebuffAI/codebuff / suffixPrefixOverlap

Function suffixPrefixOverlap

common/src/util/string.ts:413–422  ·  view source on GitHub ↗
(source: string, next: string)

Source from the content-addressed store, hash-verified

411 * @returns The longest overlapping edge, or an empty string if none exists.
412 */
413export function suffixPrefixOverlap(source: string, next: string): string {
414 for (let len = next.length; len >= 0; len--) {
415 const prefix = next.slice(0, len)
416 if (source.endsWith(prefix)) {
417 return prefix
418 }
419 }
420
421 return ''
422}
423
424export const escapeString = (str: string) => {
425 return JSON.stringify(str).slice(1, -1)

Callers 1

processMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected