MCPcopy Create free account
hub / github.com/Sethispr/image-compressor / sanitizeSvg

Function sanitizeSvg

utils.ts:173–188  ·  view source on GitHub ↗
(file: File)

Source from the content-addressed store, hash-verified

171};
172
173export const sanitizeSvg = async (file: File): Promise<File> => {
174 try {
175 const text = await file.text();
176 const cleanSvg = DOMPurify.sanitize(text, {
177 USE_PROFILES: {svg: true},
178 ADD_TAGS: ['use'],
179 });
180 return new File([cleanSvg], file.name, {type: 'image/svg+xml'});
181 } catch (e) {
182 console.warn(
183 'SVG Sanitization failed, returning original (risky but fallback)',
184 e,
185 );
186 return file;
187 }
188};
189
190export const validateAndSanitizeFile = async (
191 file: File,

Callers 1

validateAndSanitizeFileFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected