Files
oh-my-opencode/src/hooks/auto-update-checker/checker/jsonc-strip.ts
T

8 lines
221 B
TypeScript
Raw Normal View History

export function stripJsonComments(json: string): string {
return json
.replace(/\\"|"(?:\\"|[^"])*"|(\/\/.*|\/\*[\s\S]*?\*\/)/g, (match, group) =>
group ? "" : match
)
.replace(/,(\s*[}\]])/g, "$1")
}