Skip to content

Commit

Permalink
Merge commit 'f06c653b9cf929b2552002c5831ed586bd2c4d2a'
Browse files Browse the repository at this point in the history
  • Loading branch information
mbest committed Mar 17, 2013
2 parents 94fb086 + f06c653 commit f039fbb
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/utils.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
ko.utils = (function () {
var stringTrimRegex = /^(\s|\u00A0)+|(\s|\u00A0)+$/g;

var objectForEach = function(obj, action) {
for (var prop in obj) {
if (obj.hasOwnProperty(prop)) {
Expand Down Expand Up @@ -192,7 +190,10 @@ ko.utils = (function () {
},

stringTrim: function (string) {
return (string || "").replace(stringTrimRegex, "");
return string === null || string === undefined ? '' :
string.trim ?
string.trim() :
string.toString().replace(/^[\s\xa0]+|[\s\xa0]+$/g, '');
},

stringTokenize: function (string, delimiter) {
Expand Down

0 comments on commit f039fbb

Please sign in to comment.