本文整理汇总了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();
});
开发者ID:acndavidd,项目名称:iDSP-admin,代码行数:48,代码来源:main.ts
示例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');
开发者ID:Crevil,项目名称:DefinitelyTyped,代码行数:31,代码来源:validator-tests.ts
注:本文中的validator.escape函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论