codefeathers / rollup-plugin-svelte-svg

Import SVG files as Svelte Components
MIT License
75 stars 13 forks source link

Plugin fails is SVG containers "%" values in and attribute #25

Closed Steakeye closed 3 years ago

Steakeye commented 3 years ago

The line source = decodeURIComponent(source); will throw an error if for example an SVG file has something like the foillowing:

  <defs>
    <linearGradient id="clion-b" x1="50%" x2="103.297%" y1="28.391%" y2="69.421%">
      <stop offset="0%" stop-color="#FF318C"/>
      <stop offset="100%" stop-color="#009AE5"/>
    </linearGradient>
  </defs>

The attributes containing % like x1="50%" will break URI decoding causing the plugin to throw a URIError as it considers the SVG source as a malformed URI.

MKRhere commented 3 years ago

Fixed in be44ca0bd82ccd9ea79f8881b707a7a9320b6f8a from v1.0.0-beta.2. More explanation here: https://github.com/codefeathers/rollup-plugin-svelte-svg/issues/23#issuecomment-864363144

Steakeye commented 3 years ago

Thanks!