MCPcopy Index your code
hub / github.com/codeaashu/claude-code / stripTrailingWhitespace

Function stripTrailingWhitespace

src/tools/FileEditTool/utils.ts:44–64  ·  view source on GitHub ↗
(str: string)

Source from the content-addressed store, hash-verified

42 * @returns The string with trailing whitespace removed from each line
43 */
44export function stripTrailingWhitespace(str: string): string {
45 // Handle different line endings: CRLF, LF, CR
46 // Use a regex that matches line endings and captures them
47 const lines = str.split(/(\r\n|\n|\r)/)
48
49 let result = ''
50 for (let i = 0; i < lines.length; i++) {
51 const part = lines[i]
52 if (part !== undefined) {
53 if (i % 2 === 0) {
54 // Even indices are line content
55 result += part.replace(/\s+$/, '')
56 } else {
57 // Odd indices are line endings
58 result += part
59 }
60 }
61 }
62
63 return result
64}
65
66/**
67 * Finds the actual string in the file content that matches the search string,

Callers 2

normalizeFileEditInputFunction · 0.85
normalizeToolInputFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected