TypeError: Cannot convert a Symbol value to a string
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)
These are the supported values: https://github.com/sindresorhus/query-string/blob/20992772758fc74188db64e789535469adaf241f/index.d.ts#L398-L403
I guess we could improve the readme to mention those too, and also throw a more human-friendly error.
@sindresorhus I feel like the Symbol value being ignored that would be better
I disagree. That could hide bugs. I prefer strict type checking. This is also how the browser API works:
new URLSearchParams({foo: Symbol()})
//=> Uncaught TypeError: Cannot convert a Symbol value to a string
@sindresorhus but other packages like qs and querystringify work well if give a Symbol value.
That is not a good argument for doing it.
@sindresorhus anyway, it's up to you
@sindresorhus Yes you were right, Symbol should not be converted to string , from mdn web docs

We are having a similar issue encodeURIComponent(...).replaceAll is not a function in:
TypeError: encodeURIComponent(...).replaceAll is not a function
at strictUriEncode(../node_modules/query-string/base.js:8:62)
at encode(../node_modules/query-string/base.js:256:27)
at map(../node_modules/query-string/base.js:450:10)
at Array.map(<anonymous>)
at stringify(../node_modules/query-string/base.js:429:14)
It's only happening to users on Edge 122. A very strange errror.
The code is:
const search = queryString.stringify({
'redirect-to': `${location.pathname}${location.search}`,
});