You've already forked search-query-parser
set an empty string when string was not provided
preventing TypeError: Cannot read property 'trim' of undefined or TypeError: Cannot read property 'trim' of null
This commit is contained in:
@@ -11,6 +11,10 @@ exports.parse = function (string, options) {
|
||||
options = {};
|
||||
}
|
||||
|
||||
if (!string) {
|
||||
string = '';
|
||||
}
|
||||
|
||||
// Regularize white spacing
|
||||
// Make in-between white spaces a unique space
|
||||
string = string.trim().replace(/\s+/g, ' ');
|
||||
|
||||
Reference in New Issue
Block a user