Skip to content

TypeError: Cannot convert a Symbol value to a string #312

Open
@fengxinming

Description

@fengxinming

I am not sure if the Symbol value would be ignored

const { stringify } = require('query-string');

stringify({ a: () => (1), b: Symbol('test') });
module.exports = str => encodeURIComponent(str).replace(/[!'()*]/g, x => `%${x.charCodeAt(0).toString(16).toUpperCase()}`);
                        ^

TypeError: Cannot convert a Symbol value to a string
    at encodeURIComponent (<anonymous>)
    at module.exports (/Users/jesse/workspace/iot-cloud-fe/iot-cloud-util/benchmark/node_modules/[email protected]@strict-uri-encode/index.js:2:25)
    at encode (/Users/jesse/workspace/iot-cloud-fe/iot-cloud-util/benchmark/node_modules/[email protected]@query-string/index.js:188:27)
    at /Users/jesse/workspace/iot-cloud-fe/iot-cloud-util/benchmark/node_modules/[email protected]@query-string/index.js:382:39
    at Array.map (<anonymous>)
    at exports.stringify (/Users/jesse/workspace/iot-cloud-fe/iot-cloud-util/benchmark/node_modules/[email protected]@query-string/index.js:361:14)
    at Object.<anonymous> (/Users/jesse/workspace/iot-cloud-fe/iot-cloud-util/benchmark/query-string.js:12:1)
    at Module._compile (internal/modules/cjs/loader.js:1063:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
    at Module.load (internal/modules/cjs/loader.js:928:32)

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions