本文整理汇总了TypeScript中validator.escape函数的典型用法代码示例。如果您正苦于以下问题:TypeScript escape函数的具体用法?TypeScript escape怎么用?TypeScript escape使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了escape函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: pNext
vApp.use(function(pRequest, pResponse, pNext) {
// Allow access control origin
let vAllow: string;
let vOrigin: string = pRequest.get('origin');
if (vOrigin == 'http://localhost:3000') {
vAllow = 'http://localhost:3000';
}
if(vAllow) {
pResponse.header('Access-Control-Allow-Origin', vAllow);
}
pResponse.header('Access-Control-Allow-Credentials', 'true');
pResponse.header('Access-Control-Allow-Headers',
'Access-Control-Allow-Origin, X-Requested-With, Content-Type, Accept,Authorization,Proxy-Authorization,X-session');
pResponse.header('Access-Control-Allow-Methods','GET,PUT,DELETE,POST');
if(
pRequest.path !== '/service/login' &&
pRequest.path !== '/service/login/MPIN' &&
pRequest.path !== '/service/generateCallPlan' &&
pRequest.path.indexOf('/testing') !== -1 //bypass token for testing purpose
){
if(pRequest.method !== 'OPTIONS') {
// all request to service will validate token except login & logout
var vToken = '';
try{
if(pRequest.cookies['accessToken']){//accessed from web
vToken = vCookieParser.JSONCookies(pRequest.cookies).accessToken;
}else{ // accessed from mobile
vToken = pRequest.get('Authorization');
vToken = vToken.replace('Bearer ','');
}
console.log(vToken);
var jwt = vTokenSvc.verifyToken(vToken);
pResponse.locals.jwt = jwt;
}catch(pErr){
console.log('Error while parsing token : ' + pErr);
pResponse.sendStatus(403);
}
}
}
// Sanitize all the parameter send with POST request
if(pRequest.method === 'POST') {
for(let param in pRequest.body) {
pRequest.body[param] = vValidator.escape(pRequest.body[param]);
}
}
pNext();
});
示例2:
result = validator.isWhitelisted('sample', ['a', 'b', 'c']);
result = validator.matches('foobar', 'foo/i');
result = validator.matches('foobar', 'foo', 'i');
}
// **************
// * Sanitizers *
// **************
{
let result: string;
result = validator.blacklist('sample', 'abc');
result = validator.escape('sample');
result = validator.unescape('sample');
result = validator.ltrim('sample');
result = validator.ltrim('sample', ' ');
let normalizeEmailOptions: ValidatorJS.NormalizeEmailOptions;
let normalizeResult: string | false;
normalizeResult = validator.normalizeEmail('sample');
normalizeResult = validator.normalizeEmail('sample', normalizeEmailOptions);
result = validator.rtrim('sample');
result = validator.rtrim('sample', ' ');
result = validator.stripLow('sample');