^data:((?:\w+\/(?:(?!;).)+)?)((?:;[\w\W]*?[^;])*),(.+)$
test this pattern on regexr: https://regexr.com/4inht
regex pattern to match RFC 2397 data URL
dataurl := "data:" [ mediatype ] [ ";base64" ] "," data mediatype := [ type "/" subtype ] *( ";" parameter ) data := *urlchar parameter := attribute "=" value
data:image/jpeg;base64,UEsDBBQAAAAI
data:image/jpeg;key=value;base64,UEsDBBQAAAAI
data:image/jpeg;key=value,UEsDBBQAAAAI
data:;base64;sdfgsdfgsdfasdfa=s,UEsDBBQAAAAI
data:,UEsDBBQAAAAI
and about https://bit.dev/chriso/validator-js/is-data-uri you should know, it is a NPM package. and any packages could have bugs.