当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript querystring.escape函数代码示例

本文整理汇总了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");
     });
 });
开发者ID:crossroads-education,项目名称:eta-front,代码行数:28,代码来源:apply.ts

示例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");
 });
开发者ID:crossroads-education,项目名称:eta-front,代码行数:8,代码来源:contact.ts

示例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");
 });
开发者ID:crossroads-education,项目名称:eta-front,代码行数:8,代码来源:apply.ts

示例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());
     }
 });
开发者ID:crossroads-education,项目名称:eta-sys,代码行数:9,代码来源:settings.ts

示例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();
}
开发者ID:valtech,项目名称:valtech-shortie,代码行数:9,代码来源:middleware.ts

示例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;
	}
开发者ID:NativeScript,项目名称:nativescript-cli,代码行数:11,代码来源:qr.ts

示例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");
         });
     });
 }
开发者ID:crossroads-education,项目名称:eta-front,代码行数:45,代码来源:apply.ts

示例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'
开发者ID:Crevil,项目名称:DefinitelyTyped,代码行数:31,代码来源:node-tests.ts

示例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', '..');
开发者ID:demurgos,项目名称:env-node,代码行数:31,代码来源:index.ts

示例10: percentEncode

export function percentEncode(input: string): string {
  return qs.escape(input)
           .replace(/[!'()*]/g, c => `%${c.charCodeAt(0).toString(16)}`);
}
开发者ID:hashedhyphen,项目名称:twix,代码行数:4,代码来源:utils.ts


注:本文中的querystring.escape函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。