You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
16 lines
1.2 KiB
16 lines
1.2 KiB
var isBase64 = require('is-base64');
|
|
|
|
var string = 'iVBORw0KGgoAAAANSUhEUgAABQAAAALQAQMAAAD1s08VAAAAA1BMVEX/AAAZ4gk3AAAAh0lEQVR42u3BMQEAAADCoPVPbQlPoAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAB4GsTfAAGc95RKAAAAAElFTkSuQmCC';
|
|
var stringWithMime = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAABQAAAALQAQMAAAD1s08VAAAAA1BMVEX/AAAZ4gk3AAAAh0lEQVR42u3BMQEAAADCoPVPbQlPoAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAB4GsTfAAGc95RKAAAAAElFTkSuQmCC';
|
|
|
|
console.log(isBase64(string)); // true
|
|
console.log(isBase64(stringWithMime)); // false
|
|
console.log(isBase64(stringWithMime, {mime: true})); // true
|
|
console.log(isBase64('1342234')); // false
|
|
console.log(isBase64('afQ$%rfew')); // false
|
|
console.log(isBase64('dfasdfr342')); // false
|
|
console.log(isBase64('uuLMhh==')); // true
|
|
console.log(isBase64('uuLMhh')); // false
|
|
console.log(isBase64('uuLMhh', {paddingRequired: false})); // true
|
|
console.log(isBase64('')); // true
|
|
console.log(isBase64('', {allowBlank: false})); // false
|
|
|