File tree Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Original file line number Diff line number Diff line change 11import assertString from './util/assertString' ;
22import merge from './util/merge' ;
33
4- const base64WithPadding = / ^ (?: [ A - Z a - z 0 - 9 + / ] { 4 } ) * (?: [ A - Z a - z 0 - 9 + / ] { 2 } = = | [ A - Z a - z 0 - 9 + / ] { 3 } = | [ A - Z a - z 0 - 9 + / ] { 4 } ) $ / ;
4+ const base64WithPadding = / ^ [ A - Z a - z 0 - 9 + / ] + = { 0 , 2 } $ / ;
55const base64WithoutPadding = / ^ [ A - Z a - z 0 - 9 + / ] + $ / ;
6- const base64UrlWithPadding = / ^ (?: [ A - Z a - z 0 - 9 _ - ] { 4 } ) * (?: [ A - Z a - z 0 - 9 _ - ] { 2 } = = | [ A - Z a - z 0 - 9 _ - ] { 3 } = | [ A - Z a - z 0 - 9 _ - ] { 4 } ) $ / ;
6+ const base64UrlWithPadding = / ^ [ A - Z a - z 0 - 9 _ - ] + = { 0 , 2 } $ / ;
77const base64UrlWithoutPadding = / ^ [ A - Z a - z 0 - 9 _ - ] + $ / ;
88
99export default function isBase64 ( str , options ) {
@@ -12,6 +12,8 @@ export default function isBase64(str, options) {
1212
1313 if ( str === '' ) return true ;
1414
15+ if ( options . padding && str . length % 4 !== 0 ) return false ;
16+
1517 let regex ;
1618 if ( options . urlSafe ) {
1719 regex = options . padding ? base64UrlWithPadding : base64UrlWithoutPadding ;
You can’t perform that action at this time.
0 commit comments