Skip to content

Commit

Permalink
[Fix] ensure node 0.12 can stringify Symbols
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed Jun 26, 2019
1 parent 14c69e6 commit 3b40167
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,12 @@ var encode = function encode(str, defaultEncoder, charset) {
return str;
}

var string = typeof str === 'string' ? str : String(str);
var string = str;
if (typeof str === 'symbol') {
string = Symbol.prototype.toString.call(str);
} else if (typeof str !== 'string') {
string = String(str);
}

if (charset === 'iso-8859-1') {
return escape(string).replace(/%u[0-9a-f]{4}/gi, function ($0) {
Expand Down

0 comments on commit 3b40167

Please sign in to comment.