Corrected Nodejs querystring (un)escape definitions

This commit is contained in:
atrakeur
2015-02-13 23:07:01 +01:00
parent 7d298be1db
commit a5c37c4ea3
5 changed files with 28 additions and 6 deletions

View File

@@ -10,6 +10,7 @@ import crypto = require("crypto");
import http = require("http");
import net = require("net");
import dgram = require("dgram");
import querystring = require('querystring');
assert(1 + 1 - 2 === 0, "The universe isn't how it should.");
@@ -122,4 +123,14 @@ 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

4
node/node-0.11.d.ts vendored
View File

@@ -250,8 +250,8 @@ declare module "buffer" {
declare module "querystring" {
export function stringify(obj: any, sep?: string, eq?: string): string;
export function parse(str: string, sep?: string, eq?: string, options?: { maxKeys?: number; }): any;
export function escape(): any;
export function unescape(): any;
export function escape(str: string): string;
export function unescape(str: string): string;
}
declare module "events" {

View File

@@ -203,8 +203,8 @@ interface Buffer {
declare module "querystring" {
export function stringify(obj: any, sep?: string, eq?: string): string;
export function parse(str: string, sep?: string, eq?: string, options?: { maxKeys?: number; }): any;
export function escape(): any;
export function unescape(): any;
export function escape(str: string): string;
export function unescape(str: string): string;
}
declare module "events" {

View File

@@ -10,6 +10,7 @@ import crypto = require("crypto");
import http = require("http");
import net = require("net");
import dgram = require("dgram");
import querystring = require('querystring');
assert(1 + 1 - 2 === 0, "The universe isn't how it should.");
@@ -165,4 +166,14 @@ 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

4
node/node.d.ts vendored
View File

@@ -250,8 +250,8 @@ declare module "buffer" {
declare module "querystring" {
export function stringify(obj: any, sep?: string, eq?: string): string;
export function parse(str: string, sep?: string, eq?: string, options?: { maxKeys?: number; }): any;
export function escape(): any;
export function unescape(): any;
export function escape(str: string): string;
export function unescape(str: string): string;
}
declare module "events" {