fix(core): update
This commit is contained in:
parent
201812e182
commit
bd7888f7ce
@ -3,14 +3,14 @@ image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
|||||||
|
|
||||||
cache:
|
cache:
|
||||||
paths:
|
paths:
|
||||||
- .npmci_cache/
|
- .npmci_cache/
|
||||||
key: "$CI_BUILD_STAGE"
|
key: '$CI_BUILD_STAGE'
|
||||||
|
|
||||||
stages:
|
stages:
|
||||||
- security
|
- security
|
||||||
- test
|
- test
|
||||||
- release
|
- release
|
||||||
- metadata
|
- metadata
|
||||||
|
|
||||||
# ====================
|
# ====================
|
||||||
# security stage
|
# security stage
|
||||||
@ -18,21 +18,23 @@ stages:
|
|||||||
mirror:
|
mirror:
|
||||||
stage: security
|
stage: security
|
||||||
script:
|
script:
|
||||||
- npmci git mirror
|
- npmci git mirror
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- lossless
|
||||||
- notpriv
|
- docker
|
||||||
|
- notpriv
|
||||||
|
|
||||||
snyk:
|
snyk:
|
||||||
|
image: registry.gitlab.com/hosttoday/ht-docker-node:snyk
|
||||||
stage: security
|
stage: security
|
||||||
script:
|
script:
|
||||||
- npmci npm prepare
|
- npmci npm prepare
|
||||||
- npmci command npm install -g snyk
|
|
||||||
- npmci command npm install --ignore-scripts
|
- npmci command npm install --ignore-scripts
|
||||||
- npmci command snyk test
|
- npmci command snyk test
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- lossless
|
||||||
- notpriv
|
- docker
|
||||||
|
- notpriv
|
||||||
|
|
||||||
# ====================
|
# ====================
|
||||||
# test stage
|
# test stage
|
||||||
@ -41,37 +43,40 @@ snyk:
|
|||||||
testStable:
|
testStable:
|
||||||
stage: test
|
stage: test
|
||||||
script:
|
script:
|
||||||
- npmci npm prepare
|
- npmci npm prepare
|
||||||
- npmci node install stable
|
- npmci node install stable
|
||||||
- npmci npm install
|
- npmci npm install
|
||||||
- npmci npm test
|
- npmci npm test
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
coverage: /\d+.?\d+?\%\s*coverage/
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- lossless
|
||||||
- priv
|
- docker
|
||||||
|
- priv
|
||||||
|
|
||||||
testBuild:
|
testBuild:
|
||||||
stage: test
|
stage: test
|
||||||
script:
|
script:
|
||||||
- npmci npm prepare
|
- npmci npm prepare
|
||||||
- npmci node install stable
|
- npmci node install stable
|
||||||
- npmci npm install
|
- npmci npm install
|
||||||
- npmci command npm run build
|
- npmci command npm run build
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
coverage: /\d+.?\d+?\%\s*coverage/
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- lossless
|
||||||
- notpriv
|
- docker
|
||||||
|
- notpriv
|
||||||
|
|
||||||
release:
|
release:
|
||||||
stage: release
|
stage: release
|
||||||
script:
|
script:
|
||||||
- npmci node install stable
|
- npmci node install stable
|
||||||
- npmci npm publish
|
- npmci npm publish
|
||||||
only:
|
only:
|
||||||
- tags
|
- tags
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- lossless
|
||||||
- notpriv
|
- docker
|
||||||
|
- notpriv
|
||||||
|
|
||||||
# ====================
|
# ====================
|
||||||
# metadata stage
|
# metadata stage
|
||||||
@ -85,30 +90,31 @@ codequality:
|
|||||||
- npmci npm install
|
- npmci npm install
|
||||||
- npmci command "tslint -c tslint.json ./ts/**/*.ts"
|
- npmci command "tslint -c tslint.json ./ts/**/*.ts"
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- lossless
|
||||||
- priv
|
- docker
|
||||||
|
- priv
|
||||||
|
|
||||||
trigger:
|
trigger:
|
||||||
stage: metadata
|
stage: metadata
|
||||||
script:
|
script:
|
||||||
- npmci trigger
|
- npmci trigger
|
||||||
only:
|
only:
|
||||||
- tags
|
- tags
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- lossless
|
||||||
- notpriv
|
- docker
|
||||||
|
- notpriv
|
||||||
|
|
||||||
pages:
|
pages:
|
||||||
image: hosttoday/ht-docker-dbase:npmci
|
|
||||||
services:
|
|
||||||
- docker:stable-dind
|
|
||||||
stage: metadata
|
stage: metadata
|
||||||
script:
|
script:
|
||||||
|
- npmci node install lts
|
||||||
- npmci command npm install -g @gitzone/tsdoc
|
- npmci command npm install -g @gitzone/tsdoc
|
||||||
- npmci npm prepare
|
- npmci npm prepare
|
||||||
- npmci npm install
|
- npmci npm install
|
||||||
- npmci command tsdoc
|
- npmci command tsdoc
|
||||||
tags:
|
tags:
|
||||||
|
- lossless
|
||||||
- docker
|
- docker
|
||||||
- notpriv
|
- notpriv
|
||||||
only:
|
only:
|
||||||
@ -116,5 +122,5 @@ pages:
|
|||||||
artifacts:
|
artifacts:
|
||||||
expire_in: 1 week
|
expire_in: 1 week
|
||||||
paths:
|
paths:
|
||||||
- public
|
- public
|
||||||
allow_failure: true
|
allow_failure: true
|
||||||
|
66
README.md
66
README.md
@ -1,66 +0,0 @@
|
|||||||
# @pushrocks/smartstring
|
|
||||||
handle strings in smart ways. TypeScript ready.
|
|
||||||
|
|
||||||
## Availabililty and Links
|
|
||||||
* [npmjs.org (npm package)](https://www.npmjs.com/package/@pushrocks/smartstring)
|
|
||||||
* [gitlab.com (source)](https://gitlab.com/pushrocks/smartstring)
|
|
||||||
* [github.com (source mirror)](https://github.com/pushrocks/smartstring)
|
|
||||||
* [docs (typedoc)](https://pushrocks.gitlab.io/smartstring/)
|
|
||||||
|
|
||||||
## Status for master
|
|
||||||
[![build status](https://gitlab.com/pushrocks/smartstring/badges/master/build.svg)](https://gitlab.com/pushrocks/smartstring/commits/master)
|
|
||||||
[![coverage report](https://gitlab.com/pushrocks/smartstring/badges/master/coverage.svg)](https://gitlab.com/pushrocks/smartstring/commits/master)
|
|
||||||
[![npm downloads per month](https://img.shields.io/npm/dm/@pushrocks/smartstring.svg)](https://www.npmjs.com/package/@pushrocks/smartstring)
|
|
||||||
[![Known Vulnerabilities](https://snyk.io/test/npm/@pushrocks/smartstring/badge.svg)](https://snyk.io/test/npm/@pushrocks/smartstring)
|
|
||||||
[![TypeScript](https://img.shields.io/badge/TypeScript->=%203.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
|
||||||
[![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
|
||||||
[![JavaScript Style Guide](https://img.shields.io/badge/code%20style-prettier-ff69b4.svg)](https://prettier.io/)
|
|
||||||
|
|
||||||
## Usage
|
|
||||||
|
|
||||||
Use TypeScript for best in class instellisense.
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
import * as smartstring from 'smartstring';
|
|
||||||
|
|
||||||
// classes
|
|
||||||
|
|
||||||
// smartstring.Domain class
|
|
||||||
let myDomain = new smartstring.Domain('https://sub.main.tld');
|
|
||||||
myDomain.level1; // "tld"
|
|
||||||
myDomain.level2; // "main"
|
|
||||||
// level3 , level 4 and so on...
|
|
||||||
myDomain.zoneName; // "main.tld"
|
|
||||||
myDOmain.protocol; // "https"
|
|
||||||
|
|
||||||
// smartstring.GitRepo class
|
|
||||||
let myGitRepo = new smartstring.GitRepo('git@github.com:someorg/somerepo.git'); // takes https and git and npm repo URL versions
|
|
||||||
myGitRepo.host; // "github.com"
|
|
||||||
myGitRepo.user; // "someorg"
|
|
||||||
myGitRepo.repo; // "somerepo"
|
|
||||||
myGitRepo.accessToken; // accessToken if specified with https
|
|
||||||
myGitRepo.sshUrl; // "git@github.com:someorg/somerepo.git" (computed also from https)
|
|
||||||
myGitRepo.httpsUrl; // "https://github.com/someorg/somerepo.git" (computed also from ssh)
|
|
||||||
|
|
||||||
//smartstring.Base64
|
|
||||||
let myBase64 = new smartstring.Base64('somestring', 'string'); // first arg is the string, second is string type (can be string, base64, base64uri)
|
|
||||||
myBase64.simpleString; // 'somestring'
|
|
||||||
myBase64.base64String; // base64 representation of 'somestring'
|
|
||||||
myBase64.base64UriString; // base64uri representation of 'sometring'
|
|
||||||
|
|
||||||
// methods
|
|
||||||
smartstring.base64.encode('somestring'); // encodes 'somestring' to base64
|
|
||||||
smartstring.base64.encodeUri('sometring'); // encodes 'somestring' to base64uri
|
|
||||||
smartstring.base64.decode(); // decodes base64 and base64uri to simple string respresentation
|
|
||||||
|
|
||||||
smartstring.indent.indent('somestringanotherstring', 4); // indents a string by 4
|
|
||||||
smartstring.indent.indent('somestringanotherstring', '>>>> '); // indents a string with a prefix
|
|
||||||
smartstring.indent.normalize(' somestring anotherstring', '>>>> '); // looks for the least amount of indention and removes superflouous space
|
|
||||||
```
|
|
||||||
|
|
||||||
For further information read the linked docs at the top of this readme.
|
|
||||||
|
|
||||||
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
|
||||||
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
|
|
||||||
|
|
||||||
[![repo-footer](https://lossless.gitlab.io/publicrelations/repofooter.svg)](https://maintainedby.lossless.com)
|
|
@ -50,4 +50,4 @@
|
|||||||
"npmextra.json",
|
"npmextra.json",
|
||||||
"readme.md"
|
"readme.md"
|
||||||
]
|
]
|
||||||
}
|
}
|
@ -20,7 +20,8 @@ export const isUtf8 = (stringArg: string) => {
|
|||||||
// non-overlong 2-byte
|
// non-overlong 2-byte
|
||||||
0xc2 <= bytes[i] &&
|
0xc2 <= bytes[i] &&
|
||||||
bytes[i] <= 0xdf &&
|
bytes[i] <= 0xdf &&
|
||||||
(0x80 <= bytes[i + 1] && bytes[i + 1] <= 0xbf)
|
0x80 <= bytes[i + 1] &&
|
||||||
|
bytes[i + 1] <= 0xbf
|
||||||
) {
|
) {
|
||||||
i += 2;
|
i += 2;
|
||||||
continue;
|
continue;
|
||||||
@ -29,14 +30,20 @@ export const isUtf8 = (stringArg: string) => {
|
|||||||
if (
|
if (
|
||||||
// excluding overlongs
|
// excluding overlongs
|
||||||
(bytes[i] === 0xe0 &&
|
(bytes[i] === 0xe0 &&
|
||||||
(0xa0 <= bytes[i + 1] && bytes[i + 1] <= 0xbf) &&
|
0xa0 <= bytes[i + 1] &&
|
||||||
(0x80 <= bytes[i + 2] && bytes[i + 2] <= 0xbf)) || // straight 3-byte
|
bytes[i + 1] <= 0xbf &&
|
||||||
|
0x80 <= bytes[i + 2] &&
|
||||||
|
bytes[i + 2] <= 0xbf) || // straight 3-byte
|
||||||
(((0xe1 <= bytes[i] && bytes[i] <= 0xec) || bytes[i] === 0xee || bytes[i] === 0xef) &&
|
(((0xe1 <= bytes[i] && bytes[i] <= 0xec) || bytes[i] === 0xee || bytes[i] === 0xef) &&
|
||||||
(0x80 <= bytes[i + 1] && bytes[i + 1] <= 0xbf) &&
|
0x80 <= bytes[i + 1] &&
|
||||||
(0x80 <= bytes[i + 2] && bytes[i + 2] <= 0xbf)) || // excluding surrogates
|
bytes[i + 1] <= 0xbf &&
|
||||||
|
0x80 <= bytes[i + 2] &&
|
||||||
|
bytes[i + 2] <= 0xbf) || // excluding surrogates
|
||||||
(bytes[i] === 0xed &&
|
(bytes[i] === 0xed &&
|
||||||
(0x80 <= bytes[i + 1] && bytes[i + 1] <= 0x9f) &&
|
0x80 <= bytes[i + 1] &&
|
||||||
(0x80 <= bytes[i + 2] && bytes[i + 2] <= 0xbf))
|
bytes[i + 1] <= 0x9f &&
|
||||||
|
0x80 <= bytes[i + 2] &&
|
||||||
|
bytes[i + 2] <= 0xbf)
|
||||||
) {
|
) {
|
||||||
i += 3;
|
i += 3;
|
||||||
continue;
|
continue;
|
||||||
@ -45,18 +52,27 @@ export const isUtf8 = (stringArg: string) => {
|
|||||||
if (
|
if (
|
||||||
// planes 1-3
|
// planes 1-3
|
||||||
(bytes[i] === 0xf0 &&
|
(bytes[i] === 0xf0 &&
|
||||||
(0x90 <= bytes[i + 1] && bytes[i + 1] <= 0xbf) &&
|
0x90 <= bytes[i + 1] &&
|
||||||
(0x80 <= bytes[i + 2] && bytes[i + 2] <= 0xbf) &&
|
bytes[i + 1] <= 0xbf &&
|
||||||
(0x80 <= bytes[i + 3] && bytes[i + 3] <= 0xbf)) || // planes 4-15
|
0x80 <= bytes[i + 2] &&
|
||||||
|
bytes[i + 2] <= 0xbf &&
|
||||||
|
0x80 <= bytes[i + 3] &&
|
||||||
|
bytes[i + 3] <= 0xbf) || // planes 4-15
|
||||||
(0xf1 <= bytes[i] &&
|
(0xf1 <= bytes[i] &&
|
||||||
bytes[i] <= 0xf3 &&
|
bytes[i] <= 0xf3 &&
|
||||||
(0x80 <= bytes[i + 1] && bytes[i + 1] <= 0xbf) &&
|
0x80 <= bytes[i + 1] &&
|
||||||
(0x80 <= bytes[i + 2] && bytes[i + 2] <= 0xbf) &&
|
bytes[i + 1] <= 0xbf &&
|
||||||
(0x80 <= bytes[i + 3] && bytes[i + 3] <= 0xbf)) || // plane 16
|
0x80 <= bytes[i + 2] &&
|
||||||
|
bytes[i + 2] <= 0xbf &&
|
||||||
|
0x80 <= bytes[i + 3] &&
|
||||||
|
bytes[i + 3] <= 0xbf) || // plane 16
|
||||||
(bytes[i] === 0xf4 &&
|
(bytes[i] === 0xf4 &&
|
||||||
(0x80 <= bytes[i + 1] && bytes[i + 1] <= 0x8f) &&
|
0x80 <= bytes[i + 1] &&
|
||||||
(0x80 <= bytes[i + 2] && bytes[i + 2] <= 0xbf) &&
|
bytes[i + 1] <= 0x8f &&
|
||||||
(0x80 <= bytes[i + 3] && bytes[i + 3] <= 0xbf))
|
0x80 <= bytes[i + 2] &&
|
||||||
|
bytes[i + 2] <= 0xbf &&
|
||||||
|
0x80 <= bytes[i + 3] &&
|
||||||
|
bytes[i + 3] <= 0xbf)
|
||||||
) {
|
) {
|
||||||
i += 4;
|
i += 4;
|
||||||
continue;
|
continue;
|
||||||
@ -75,7 +91,9 @@ export const isBase64 = (stringArg: string) => {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const firstPaddingChar = stringArg.indexOf('=');
|
const firstPaddingChar = stringArg.indexOf('=');
|
||||||
return firstPaddingChar === -1 ||
|
return (
|
||||||
|
firstPaddingChar === -1 ||
|
||||||
firstPaddingChar === len - 1 ||
|
firstPaddingChar === len - 1 ||
|
||||||
(firstPaddingChar === len - 2 && stringArg[len - 1] === '=');
|
(firstPaddingChar === len - 2 && stringArg[len - 1] === '=')
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user