Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
9b9675bd96 | |||
e7d7865750 | |||
b7feb5098b | |||
76fcf14831 | |||
50e14811d4 | |||
f7e5af4113 |
@ -19,23 +19,35 @@ mirror:
|
||||
stage: security
|
||||
script:
|
||||
- npmci git mirror
|
||||
only:
|
||||
- tags
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
audit:
|
||||
auditProductionDependencies:
|
||||
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||
stage: security
|
||||
script:
|
||||
- npmci npm prepare
|
||||
- npmci command npm install --production --ignore-scripts
|
||||
- npmci command npm config set registry https://registry.npmjs.org
|
||||
- npmci command npm audit --audit-level=high --only=prod --production
|
||||
tags:
|
||||
- docker
|
||||
|
||||
auditDevDependencies:
|
||||
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||
stage: security
|
||||
script:
|
||||
- npmci npm prepare
|
||||
- npmci command npm install --ignore-scripts
|
||||
- npmci command npm config set registry https://registry.npmjs.org
|
||||
- npmci command npm audit --audit-level=high
|
||||
- npmci command npm audit --audit-level=high --only=dev
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
- notpriv
|
||||
allow_failure: true
|
||||
|
||||
# ====================
|
||||
# test stage
|
||||
@ -50,9 +62,7 @@ testStable:
|
||||
- npmci npm test
|
||||
coverage: /\d+.?\d+?\%\s*coverage/
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
- priv
|
||||
|
||||
testBuild:
|
||||
stage: test
|
||||
@ -63,9 +73,7 @@ testBuild:
|
||||
- npmci command npm run build
|
||||
coverage: /\d+.?\d+?\%\s*coverage/
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
release:
|
||||
stage: release
|
||||
@ -85,6 +93,8 @@ release:
|
||||
codequality:
|
||||
stage: metadata
|
||||
allow_failure: true
|
||||
only:
|
||||
- tags
|
||||
script:
|
||||
- npmci command npm install -g tslint typescript
|
||||
- npmci npm prepare
|
||||
|
2
.vscode/settings.json
vendored
2
.vscode/settings.json
vendored
@ -15,7 +15,7 @@
|
||||
"properties": {
|
||||
"projectType": {
|
||||
"type": "string",
|
||||
"enum": ["website", "element", "service", "npm"]
|
||||
"enum": ["website", "element", "service", "npm", "wcc"]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
2
package-lock.json
generated
2
package-lock.json
generated
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@pushrocks/smartrouter",
|
||||
"version": "1.0.4",
|
||||
"version": "1.0.7",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@pushrocks/smartrouter",
|
||||
"version": "1.0.4",
|
||||
"version": "1.0.7",
|
||||
"private": false,
|
||||
"description": "a router for routing on websites",
|
||||
"main": "dist_ts/index.js",
|
||||
|
10
ts/index.ts
10
ts/index.ts
@ -11,8 +11,8 @@ export interface IRouterOptions {
|
||||
export type THandlerFunction = <T extends object>(routeArg: IRouteInfo) => Promise<any>;
|
||||
export interface IRouteInfo {
|
||||
path: string;
|
||||
index:number;
|
||||
params: {[key: string]: string};
|
||||
index: number;
|
||||
params: { [key: string]: string };
|
||||
}
|
||||
|
||||
/**
|
||||
@ -80,13 +80,13 @@ export class SmartRouter {
|
||||
*/
|
||||
async _handleRouteState() {
|
||||
const currentLocation = window.location.pathname;
|
||||
const wantedRoute = this.routes.find((routeArg) => {
|
||||
const wantedRoutes = this.routes.filter((routeArg) => {
|
||||
return !!routeArg.matchFunction(currentLocation);
|
||||
});
|
||||
|
||||
if (wantedRoute) {
|
||||
for (const wantedRoute of wantedRoutes) {
|
||||
const routeResult = wantedRoute.matchFunction(currentLocation);
|
||||
await wantedRoute.handler(routeResult.valueOf() as IRouteInfo);
|
||||
wantedRoute.handler(routeResult.valueOf() as IRouteInfo); // not waiting here
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user