diff --git a/lib/utils.js b/lib/utils.js index 28ccfff3c0..5d966f4448 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -185,7 +185,7 @@ function isURLSearchParams(val) { * @returns {String} The String freed of excess whitespace */ function trim(str) { - return str.replace(/^\s*/, '').replace(/\s*$/, ''); + return str.trim ? str.trim() : str.replace(/^\s+|\s+$/g, ''); } /**