MCPcopy Create free account
hub / github.com/isomorphic-git/isomorphic-git / removeComments

Function removeComments

src/models/GitConfig.js:82–96  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

80}
81
82const removeComments = rawValue => {
83 const commentMatches = VARIABLE_VALUE_COMMENT_REGEX.exec(rawValue)
84 if (commentMatches == null) {
85 return rawValue
86 }
87 const [valueWithoutComment, comment] = commentMatches.slice(1)
88 // if odd number of quotes before and after comment => comment is escaped
89 if (
90 hasOddNumberOfQuotes(valueWithoutComment) &&
91 hasOddNumberOfQuotes(comment)
92 ) {
93 return `${valueWithoutComment}${comment}`
94 }
95 return valueWithoutComment
96}
97
98const hasOddNumberOfQuotes = text => {
99 const numberOfQuotes = (text.match(/(?:^|[^\\])"/g) || []).length

Callers 1

extractVariableLineFunction · 0.85

Calls 2

hasOddNumberOfQuotesFunction · 0.85
sliceMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…