How to use the urlencode.stringify 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._prepareRequest = function(config) {
    config.requestPrepared = true;
    var path;

    var query = urlencode.stringify(config.query, {
        charset: config.encoding
    });

    if (query) {
        // didn't handle # situation since backend should not get a hash tag
        if (config.path.indexOf('?') === -1) {
            path = config.path + '?' + query;
        } else {
            path = config.path + '&' + query;
        }
    } else {
        path = config.path;
    }

    if (config.disableGzip) {
        if (config.headers && config.headers['accept-encoding']) {
github XadillaX / spidex / lib / spidex.js View on Github external
// parse url & its protocol
    var urlObject = urlHelper.parse(url);
    var protocol = urlObject.protocol;

    // charset
    var charset = opts.charset || "utf8";

    // data
    var bodyEncode = null;
    var data = opts.data || "";
    if(data instanceof Buffer) {
        // if it's raw data
        bodyEncode = "binary";
    } else if(typeof data === "object") {
        // if it's object then stringify it
        data = urlencode.stringify(data, { charset: charset });
    }

    // header
    var header = this._combineHeader(opts.header || {});
    if(!header["content-length"]) {
        header["content-length"] = (Buffer.isBuffer(data) ? data.length : Buffer.byteLength(data));
    }
    if(!header["content-type"] && method.toLowerCase() !== "get") {
        header["content-type"] = "application/x-www-form-urlencoded";
    }

    // the returned object
    var emitter = new EventEmitter();

    var p = ((protocol === "http:") ? http : ((protocol === "https:") ? https : null));
    if(!p) {
github Andro999b / torrent-player / server / service / trackers / providers / KinogoProvider.js View on Github external
_tryExtractHls(script) {
        const parts = script.match(/fhls = "([^"]+)"/)

        if(parts && parts.length > 1) {
            const manifestUrl = this._extractManifest(parts[1])

            return [{ 
                manifestUrl, 
                downloadUrl: '/videoStreamConcat?' + urlencode.stringify({ manifestUrl}) 
            }]
        }
    }
github Andro999b / torrent-player / server / service / trackers / providers / HDRezkaProvider.js View on Github external
details.files.forEach((file) => {
            const extractor = {
                type: 'streamguard',
                params: {
                    referer: resultsId
                }
            }

            file.extractor = extractor
            file.downloadUrl = '/videoStreamConcat?' + urlencode.stringify({
                manifestUrl: file.manifestUrl,
                extractor
            })
        })
github Andro999b / torrent-player / server / service / trackers / providers / KinokradProvider.js View on Github external
transform: ($el) => {
                        const script = $el.toArray()[0].children[0].data
                        const matches = script.match(/var filmSource = "([^]+)" \|\|/)

                        if(!matches) return []

                        const manifestUrl = matches[1]
                        const extractor = { type: 'direct' }

                        return [{
                            id: 0, 
                            extractor,
                            downloadUrl: '/videoStreamConcat?' + urlencode.stringify({
                                manifestUrl,
                                extractor
                            }),
                            manifestUrl
                        }]
                    }
                }
github Andro999b / torrent-player / server / utils / index.js View on Github external
function getExtractorUrl(url, extractor) {
    const { type, params } = extractor

    if (!extractor) return url

    return `http://${HOSTNAME}:${WEB_PORT}/extractVideo?` + urlencode.stringify({
        type,
        url,
        ...params
    })
}

urlencode

encodeURIComponent with charset

MIT
Latest version published 1 year ago

Package Health Score

57 / 100
Full package analysis