Skip to content

Commit 15bf4a8

Browse files
committed
Check for existence of String.prototype.trim before overwriting.
1 parent 1a302f1 commit 15bf4a8

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

parse-names.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,11 @@ Array.prototype.implode = function (separator) {
2020
}
2121
return output;
2222
};
23-
String.prototype.trim = function() {
24-
return this.replace(/^\s+|\s+$|\,$/g,"");
25-
};
23+
if (!String.prototype.trim) {
24+
String.prototype.trim = function () {
25+
return this.replace(/^\s+|\s+$/gm, '');
26+
};
27+
}
2628
String.prototype.ucfirst = function() {
2729
return this.substr(0,1).toUpperCase() + this.substr(1,this.length - 1).toLowerCase();
2830
};

0 commit comments

Comments
 (0)