13 lines
461 B
TypeScript
13 lines
461 B
TypeScript
|
|
const svg_header = /^<\?xml version="1\.0" encoding="UTF-8"\?>/;
|
|
const svg_dimensions = /^<svg[^>]* (height="[\d\.]+"\s+width="[\d\.]+"|width="[\d\.]+"\s+height="[\d\.]+")/;
|
|
|
|
// Removes fixed dimension attributes and meta-declaration from SVGs so we can scale them with CSS
|
|
export function strip_svg(svg: string) {
|
|
return svg
|
|
.replace(svg_header, '')
|
|
.replace(svg_dimensions, (match, dimensions) => {
|
|
return match.slice(0, -dimensions.length);
|
|
});
|
|
}
|