Files
moreminimore-vibe/src/ipc/utils/cleanFullResponse.ts
2025-06-19 10:08:26 -07:00

16 lines
686 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

export function cleanFullResponse(text: string): string {
// Replace < characters inside dyad-* attributes with fullwidth less-than sign
// This prevents parsing issues when attributes contain HTML tags like <a> or <div>
return text.replace(/<dyad-[^<>]*(?:"[^"]*"[^<>]*)*>/g, (match: string) => {
// Find all attribute values (content within quotes) and replace < with and > with
const processedMatch = match.replace(
/="([^"]*)"/g,
(attrMatch: string, attrValue: string) => {
const cleanedValue = attrValue.replace(/</g, "").replace(/>/g, "");
return `="${cleanedValue}"`;
},
);
return processedMatch;
});
}