fix type error in util.ts
This commit is contained in:
parent
a96b740a15
commit
e7906dd889
@ -2,8 +2,9 @@
|
|||||||
import {Context} from 'koa';
|
import {Context} from 'koa';
|
||||||
|
|
||||||
|
|
||||||
export function ParseQueryNumber(s: string|undefined): number| undefined{
|
export function ParseQueryNumber(s: string[] | string|undefined): number| undefined{
|
||||||
if(s === undefined) return undefined;
|
if(s === undefined) return undefined;
|
||||||
|
else if(typeof s === "object") return undefined;
|
||||||
else return Number.parseInt(s);
|
else return Number.parseInt(s);
|
||||||
}
|
}
|
||||||
export function ParseQueryArray(s: string[]|string|undefined){
|
export function ParseQueryArray(s: string[]|string|undefined){
|
||||||
@ -11,19 +12,20 @@ export function ParseQueryArray(s: string[]|string|undefined){
|
|||||||
const r = s instanceof Array ? s : [s];
|
const r = s instanceof Array ? s : [s];
|
||||||
return r.map(x=>decodeURIComponent(x));
|
return r.map(x=>decodeURIComponent(x));
|
||||||
}
|
}
|
||||||
export function ParseQueryArgString(s: string|undefined){
|
export function ParseQueryArgString(s: string[]|string|undefined){
|
||||||
|
if(typeof s === "object") return undefined;
|
||||||
return s === undefined ? s : decodeURIComponent(s);
|
return s === undefined ? s : decodeURIComponent(s);
|
||||||
}
|
}
|
||||||
export function ParseQueryBoolean(s: string|undefined): [boolean,boolean|undefined]{
|
export function ParseQueryBoolean(s: string[] |string|undefined): [boolean,boolean|undefined]{
|
||||||
let value:boolean|undefined;
|
let value:boolean|undefined;
|
||||||
|
|
||||||
if(s === "true")
|
if(s === "true")
|
||||||
value = true;
|
value = true;
|
||||||
else if(s === "false")
|
else if(s === "false")
|
||||||
value = false;
|
value = false;
|
||||||
else if(s === undefined)
|
else if(s === undefined)
|
||||||
value = undefined;
|
value = undefined;
|
||||||
else
|
else return [false,undefined]
|
||||||
return [false,undefined]
|
|
||||||
return [true,value]
|
return [true,value]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user