本文整理汇总了TypeScript中querystring.escape函数的典型用法代码示例。如果您正苦于以下问题:TypeScript escape函数的具体用法?TypeScript escape怎么用?TypeScript escape使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了escape函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: CURRENT_TIMESTAMP
eta.db.query(sql, [req.session["userid"]], (err: eta.DBError, rows: any[]) => {
if (err) {
eta.logger.dbError(err);
res.redirect("/apply?error=" + querystring.escape("We were unable to process your application due to an internal error."));
return;
}
let valueSql: string = "(?, ?, 1),".repeat(positions.length);
let sql: string = `
INSERT INTO ApplicantPosition
(id, position, count)
VALUES ${valueSql.substring(0, valueSql.length - 1)}
ON DUPLICATE KEY UPDATE
lastApplied = CURRENT_TIMESTAMP(),
count = count + 1`;
let params: string[] = [];
for (let i: number = 0; i < positions.length; i++) {
params.push(req.session["userid"]);
params.push(positions[i]);
}
eta.db.query(sql, params, (err: eta.DBError, rows: any[]) => {
if (err) {
eta.logger.dbError(err);
res.redirect("/apply?error=" + querystring.escape("We were unable to process your application due to an internal error."));
return;
}
res.redirect("/apply?success=true");
});
});
示例2:
}, (err: Error, info: nodemailer.SentMessageInfo) => {
if (err) {
eta.logger.warn("Could not send mail from " + req.body.email + ": " + err.message);
res.redirect("/contact?error=" + querystring.escape("failed-to-send-email"));
return;
}
res.redirect("/contact?success=true");
});
示例3:
eta.db.query(sql, params, (err: eta.DBError, rows: any[]) => {
if (err) {
eta.logger.dbError(err);
res.redirect("/apply?error=" + querystring.escape("We were unable to process your application due to an internal error."));
return;
}
res.redirect("/apply?success=true");
});
示例4:
eta.setting.set(req.body.page, req.body.name, req.body.value, req.body.type, (success: boolean) => {
eta.logger.trace("Setting set: " + success);
eta.setting.init();
if (req.body.shouldRedirect) {
res.redirect("../edit/settings?lastPage=" + querystring.escape(req.body.page));
} else {
res.send(success.toString());
}
});
示例5: requireAuthCookieOrRedirect
export function requireAuthCookieOrRedirect(req, res, next) {
if (req['authSession'].signed_in !== true) {
var url = util.format('/login?redirect=%s', qs.escape(req.path));
return res.redirect(url);
}
res.locals.user = getUser(req);
res.locals.signOutCsrfToken = req.authSession.signOutCsrfToken;
next();
}
示例6: generateDataUri
public async generateDataUri(data: string): Promise<string> {
let result: string = null;
try {
const qrSvg = imageSync(data, { size: this.$staticConfig.QR_SIZE, type: "svg" }).toString();
result = `data:image/svg+xml;utf-8,${escape(qrSvg)}`;
} catch (err) {
this.$logger.trace(`Failed to generate QR code for ${data}`, err);
}
return result;
}
示例7: render
public render(req: express.Request, res: express.Response, callback: (env: { [key: string]: any }) => void): void {
// check if a position was selected
let positions: string[] = [];
for (let param in req.body) {
if (param.startsWith("Position:")) {
positions.push(param.split(":")[1]);
}
}
if (positions.length == 0) {
res.redirect("/apply?error=" + querystring.escape("Please select positions before submitting your application."));
return;
}
let sql: string = `
INSERT IGNORE INTO Applicant
(id, notes, workStudy, phone, altEmail)
VALUES (?, '', 0, '', '')`;
eta.db.query(sql, [req.session["userid"]], (err: eta.DBError, rows: any[]) => {
if (err) {
eta.logger.dbError(err);
res.redirect("/apply?error=" + querystring.escape("We were unable to process your application due to an internal error."));
return;
}
let valueSql: string = "(?, ?, 1),".repeat(positions.length);
let sql: string = `
INSERT INTO ApplicantPosition
(id, position, count)
VALUES ${valueSql.substring(0, valueSql.length - 1)}
ON DUPLICATE KEY UPDATE
lastApplied = CURRENT_TIMESTAMP(),
count = count + 1`;
let params: string[] = [];
for (let i: number = 0; i < positions.length; i++) {
params.push(req.session["userid"]);
params.push(positions[i]);
}
eta.db.query(sql, params, (err: eta.DBError, rows: any[]) => {
if (err) {
eta.logger.dbError(err);
res.redirect("/apply?error=" + querystring.escape("We were unable to process your application due to an internal error."));
return;
}
res.redirect("/apply?success=true");
});
});
}
示例8:
let sep: string;
let eq: string;
let options: querystring.ParseOptions;
let result: SampleObject;
result = querystring.parse<SampleObject>(str);
result = querystring.parse<SampleObject>(str, sep);
result = querystring.parse<SampleObject>(str, sep, eq);
result = querystring.parse<SampleObject>(str, sep, eq, options);
}
{
let str: string;
let result: string;
result = querystring.escape(str);
result = querystring.unescape(str);
}
}
////////////////////////////////////////////////////
/// path tests : http://nodejs.org/api/path.html
////////////////////////////////////////////////////
namespace path_tests {
path.normalize('/foo/bar//baz/asdf/quux/..');
path.join('/foo', 'bar', 'baz/asdf', 'quux', '..');
// returns
//'/foo/bar/baz/asdf'
示例9: Buffer
////////////////////////////////////////////////////
/// Dgram tests : http://nodejs.org/api/dgram.html
////////////////////////////////////////////////////
var ds: dgram.Socket = dgram.createSocket("udp4", (msg: Buffer, rinfo: dgram.RemoteInfo): void => {
});
var ai: dgram.AddressInfo = ds.address();
ds.send(new Buffer("hello"), 0, 5, 5000, "127.0.0.1", (error: Error, bytes: number): void => {
});
////////////////////////////////////////////////////
///Querystring tests : https://gist.github.com/musubu/2202583
////////////////////////////////////////////////////
var original: string = 'http://example.com/product/abcde.html';
var escaped: string = querystring.escape(original);
console.log(escaped);
// http%3A%2F%2Fexample.com%2Fproduct%2Fabcde.html
var unescaped: string = querystring.unescape(escaped);
console.log(unescaped);
// http://example.com/product/abcde.html
////////////////////////////////////////////////////
/// path tests : http://nodejs.org/api/path.html
////////////////////////////////////////////////////
namespace path_tests {
path.normalize('/foo/bar//baz/asdf/quux/..');
path.join('/foo', 'bar', 'baz/asdf', 'quux', '..');
示例10: percentEncode
export function percentEncode(input: string): string {
return qs.escape(input)
.replace(/[!'()*]/g, c => `%${c.charCodeAt(0).toString(16)}`);
}