From 5e961f7a5b2a0fb766491143a21c839cb13388a1 Mon Sep 17 00:00:00 2001 From: Philipp Kunz Date: Tue, 13 Sep 2022 19:23:11 +0200 Subject: [PATCH] fix(core): update --- .gitlab-ci.yml | 16 ++-------------- package.json | 5 +++-- test/test.base64.both.ts | 7 +++++++ ts/00_commitinfo_data.ts | 2 +- ts/smartstring.base64.ts | 10 ++++++++++ 5 files changed, 23 insertions(+), 17 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 7b61eb3..69b3e08 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -18,17 +18,6 @@ before_script: # ==================== # security stage # ==================== -mirror: - stage: security - script: - - npmci git mirror - only: - - tags - tags: - - lossless - - docker - - notpriv - auditProductionDependencies: image: registry.gitlab.com/hosttoday/ht-docker-node:npmci stage: security @@ -122,11 +111,10 @@ trigger: pages: stage: metadata script: - - npmci node install lts - - npmci command npm install -g @gitzone/tsdoc + - npmci node install stable - npmci npm prepare - npmci npm install - - npmci command tsdoc + - npmci command npm run buildDocs tags: - lossless - docker diff --git a/package.json b/package.json index 92e37cb..0f0e1a3 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,8 @@ "type": "module", "scripts": { "test": "(tstest test/)", - "build": "(tsbuild --web --allowimplicitany)" + "build": "(tsbuild --web --allowimplicitany)", + "buildDocs": "tsdoc" }, "repository": { "type": "git", @@ -60,4 +61,4 @@ "browserslist": [ "last 1 chrome versions" ] -} +} \ No newline at end of file diff --git a/test/test.base64.both.ts b/test/test.base64.both.ts index ffe0fd7..8e56434 100644 --- a/test/test.base64.both.ts +++ b/test/test.base64.both.ts @@ -3,14 +3,21 @@ import { tap, expect } from '@pushrocks/tapbundle'; // Base64 let testBase64: smartstring.Base64; + tap.test('expect create a valid instance of Base64', async () => { testBase64 = new smartstring.Base64('somestring', 'string'); expect(testBase64).toBeInstanceOf(smartstring.Base64); }); + tap.test('expect read output a file as base64 and base64uri', async () => { expect(testBase64.base64String).not.toEqual(testBase64.base64UriString); let testBase64_2 = new smartstring.Base64(testBase64.base64UriString, 'base64uri'); expect(testBase64_2.simpleString).toEqual(testBase64.simpleString); }); +tap.test('should test for a valid base64 token', async () => { + const result = smartstring.base64.isBase64('dGVzdA=='); + expect(result).toBeTrue(); +}); + tap.start(); diff --git a/ts/00_commitinfo_data.ts b/ts/00_commitinfo_data.ts index 439a9f4..fa46677 100644 --- a/ts/00_commitinfo_data.ts +++ b/ts/00_commitinfo_data.ts @@ -3,6 +3,6 @@ */ export const commitinfo = { name: '@pushrocks/smartstring', - version: '4.0.4', + version: '4.0.5', description: 'handle strings in smart ways. TypeScript ready.' } diff --git a/ts/smartstring.base64.ts b/ts/smartstring.base64.ts index 31f6270..98a8bba 100644 --- a/ts/smartstring.base64.ts +++ b/ts/smartstring.base64.ts @@ -66,4 +66,14 @@ export let base64 = { decode: (stringArg: string) => { return plugins.jsBase64.decode(stringArg); }, + + /** + * + * @param stringArg + * checks wether the string is base64 encoded + */ + isBase64: (stringArg: string) => { + const regex = /^([A-Za-z0-9+/]{4})*([A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{2}==)?$/; + return regex.test(stringArg); + }, };