How to use the urlencode.parse function in urlencode

To help you get started, we’ve selected a few urlencode examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github DefinitelyTyped / DefinitelyTyped / types / urlencode / urlencode-tests.ts View on Github external
import urlencode from 'urlencode';

urlencode('苏千'); // default is utf8
urlencode('苏千', 'gbk'); // '%CB%D5%C7%A7'

// decode gbk
urlencode.decode('%CB%D5%C7%A7', 'gbk'); // '苏千'

// parse gbk querystring
urlencode.parse('nick=%CB%D5%C7%A7', {charset: 'gbk'}); // {nick: '苏千'}

// stringify obj with gbk encoding
const str = 'x[y][0][v][w]=' + urlencode('雾空', 'gbk'); // x[y][0][v][w]=%CE%ED%BF%D5
const obj =  {x: {y : [{v : {w : '雾空'}}]}};
urlencode.stringify(obj, {charset: 'gbk'});
github fex-team / node-ral / lib / ext / protocol / httpProtocolBase.js View on Github external
HttpProtocolBase.prototype.normalizeConfig = HttpProtocolBase.normalizeConfig = function(config) {
    config = Protocol.normalizeConfig(config);
    if (config.disableGzip === undefined) {
        config.disableGzip = true;
    }
    if (typeof config.query !== 'object') {
        config.query = urlencode.parse(config.query, {
            charset: config.encoding
        });
    }
    if (config.path) {
        // auto replace spaces in path
        config.path = config.path.replace(/ /g, '%20');
        if (config.path[0] !== '/') {
            config.path = '/' + config.path;
        }
    }
    // support idc proxy
    if (config.proxy && config.proxy instanceof Array) {
        var defaultProxy = null;
        var idcProxyFounded = false;
        for (var i = 0; i < config.proxy.length; i++) {
            var proxy = config.proxy[i];
github fex-team / node-ral / test / ral / server.js View on Github external
'Content-Type': 'application/json'
            });
            if (request.method === 'POST') {
                var formIn = new formidable.IncomingForm();
                formIn.encoding = encoding || 'utf-8';
                formIn.parse(request, function(err, fields) {
                    response.write(JSON.stringify({
                        port: port,
                        query: fields
                    }));
                    response.end();
                });
            } else {
                response.write(JSON.stringify({
                    port: port,
                    query: urlencode.parse(info.query)
                }));
                response.end();
            }
        }
    }).listen(port);
};

urlencode

encodeURIComponent with charset

MIT
Latest version published 1 year ago

Package Health Score

57 / 100
Full package analysis