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
Conversation
src/nodes/image.ts
Outdated
@@ -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 |
There was a problem hiding this comment.
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.
src/nodes/image.ts
Outdated
if (match[4] === 'base64') { | ||
data = data.replace(/\s/g, '') | ||
data = data.replace(/\s/g || /\n/g, '') |
There was a problem hiding this comment.
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.
No description provided.