Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle data:image/svg+xml URLs without making requests #1467

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

nathan-knight
Copy link

Vite 5 started automatically inlining small SVG files, attempting to request these with AJAX causes CSP issues, after some digging it seemed the most expedient solution was to adjust the request logic so it will avoid making a request if it is given a data URL with the correct MIME type and return the expected structure so it can be used immediately.

I haven't added new tests but I have tested this change and it resolved the issue. This isn't entirely comprehensive, there are additional cases I didn't account for like base64 encoding. If that is needed I can add it as well or this can be used as a starting point.

Relevant commit from Vite: vitejs/vite@5acda5e

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant