Support predefining types
See original GitHub issue(related to https://github.com/sindresorhus/query-string/issues/201)
Consider 2 examples:
const search1 = '?phoneNumber=%2B380951234567&subtopicId=2&topicId=1';
const result1 = queryString.parse(search, {
parseBooleans: true,
parseNumbers: true,
});
const search2 = '?phoneNumber=a%2B380951234567&subtopicId=2&topicId=1';
const result2 = queryString.parse(search, {
parseBooleans: true,
parseNumbers: true,
});
console.log('result1', result1);
// {
// phoneNumber: 380951234567,
// subtopicId: 2,
// topicId: 1,
// };
console.log('result2', result2);
// {
// phoneNumber: 'a+380951234567',
// subtopicId: 2,
// topicId: 1,
// };
In the 1st example, “+” sign (%2B
escaped) is ignored thus reducing to the number parsing, which is not what it supposed to be.
The main goal is to keep parsing numbers for parameters which values starts on the number and parse as plain string otherwise.
Does it look feasible to make a PR on this or should I not use parseNumbers
option in that case?
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (5 by maintainers)
Top Results From Across the Web
Amazon EC2 Instance Types - Amazon Web Services
Amazon EC2 provides a wide selection of instance types optimized to fit different use cases. Instance types comprise varying combinations of CPU, memory, ......
Read more >General-purpose machine family | Compute Engine ...
Support up to 96 vCPUs and 624 GB of memory. Available as both predefined machine types and custom machine types. Custom machine types...
Read more >Creating multiple ticket forms to support different request types
A ticket form is a set of predefined ticket fields for a specific support request. The ticket form determines the fields and data...
Read more >Printer Types with Predefined OCR Support - SAP Help Portal
SAP delivers definitions for many types of printers with the SAP System, some of which include support for OCR printing; that is the...
Read more >Integral numeric types - C# reference - Microsoft Learn
Characteristics of the integral types. C# supports the following predefined integral types: C# type/keyword, Range, Size .NET type ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I would prefer something like this:
The type could also be a function to let the user handle the converting it from a string to a custom type. Don’t forget that it also needs to be able to handle arrays.
If anyone wants to work on this, see the feedback given in https://github.com/sindresorhus/query-string/pull/249.