Compare commits

...

4 Commits

Author SHA1 Message Date
201812e182 3.0.15 2019-11-24 11:43:32 +00:00
8dfa3f8965 fix(core): update 2019-11-24 11:43:32 +00:00
43d50b746b 3.0.14 2019-10-10 18:24:04 +02:00
a1ee8f37d6 fix(core): update 2019-10-10 18:24:03 +02:00
4 changed files with 12 additions and 4 deletions

2
package-lock.json generated
View File

@ -1,6 +1,6 @@
{
"name": "@pushrocks/smartstring",
"version": "3.0.13",
"version": "3.0.15",
"lockfileVersion": 1,
"requires": true,
"dependencies": {

View File

@ -1,6 +1,6 @@
{
"name": "@pushrocks/smartstring",
"version": "3.0.13",
"version": "3.0.15",
"private": false,
"description": "handle strings in smart ways. TypeScript ready.",
"main": "dist/index.js",

View File

@ -1,5 +1,5 @@
// node native
import * as crypto from 'crypto';
import crypto from 'crypto';
import * as url from 'url';
export { crypto, url };

View File

@ -69,5 +69,13 @@ export const isUtf8 = (stringArg: string) => {
};
export const isBase64 = (stringArg: string) => {
return stringArg.endsWith('=');
const notBase64 = /[^A-Z0-9+\/=]/i;
const len = stringArg.length;
if (!len || len % 4 !== 0 || notBase64.test(stringArg)) {
return false;
}
const firstPaddingChar = stringArg.indexOf('=');
return firstPaddingChar === -1 ||
firstPaddingChar === len - 1 ||
(firstPaddingChar === len - 2 && stringArg[len - 1] === '=');
};