Skip to content

Consider using safer/better default 'encode' function? #42

@derzwen

Description

@derzwen

Hi,

i'm using a modified encode function in my project for month now grabbed from this very nice post without any problems:

https://codepen.io/tigt/post/optimizing-svgs-in-data-uris

Function is in this comment: https://codepen.io/tigt/post/optimizing-svgs-in-data-uris#comment-id-6931 It's feels more safe because it uses encodeURIComponent first and replaces just some characters back.

As an addition to it, I also strip the XML declaration if present after processing with something like:

svgCode.replace(/<\?xml[^>]*>/g, '');

What about using those as a default encode function?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions