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

Accept newlines in Base64 encoded data urls #268

Merged
merged 7 commits into from Aug 10, 2023
Merged

Accept newlines in Base64 encoded data urls #268

merged 7 commits into from Aug 10, 2023

Conversation

AnnaLena2704
Copy link
Contributor

No description provided.

@@ -10,7 +10,7 @@ import { Matrix } from 'jspdf'
import { Viewport } from '../context/viewport'

// groups: 1: mime-type (+ charset), 2: mime-type (w/o charset), 3: charset, 4: base64?, 5: body
export const dataUriRegex = /^\s*data:(([^/,;]+\/[^/,;]+)(?:;([^,;=]+=[^,;=]+))?)?(?:;(base64))?,(?:(.|\s)*)$/i
export const dataUriRegex = /^\s*data:(([^/,;]+\/[^/,;]+)(?:;([^,;=]+=[^,;=]+))?)?(?:;(base64))?,((?:(.|\s)*))$/i
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can replace ((?:(.|\s)*)) by ((?:.|\s)*), should do the same and has less groups.

if (match[4] === 'base64') {
data = data.replace(/\s/g, '')
data = data.replace(/\s/g || /\n/g, '')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't work. If you want to replace \s or \n, you need to put them in the same regex. But \n is part of \s, so this change is not necessary.

@HackbrettXXX HackbrettXXX changed the title fixed requested changes Accept newlines in Base64 encoded data urls Aug 10, 2023
@HackbrettXXX HackbrettXXX linked an issue Aug 10, 2023 that may be closed by this pull request
@HackbrettXXX HackbrettXXX merged commit 0598244 into yWorks:master Aug 10, 2023
1 check passed
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.

Accept spaces in data urls in image urls
2 participants