Skip to content

Commit

Permalink
Bug fix for #284 fix (String#trim).
Browse files Browse the repository at this point in the history
  • Loading branch information
cscott committed Sep 3, 2014
1 parent 31f20f4 commit eb6ba2e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion es6-shim.js
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@
'\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028',
'\u2029\uFEFF'
].join('');
var trimRegexp = new RegExp('(^[' + ws + ']+|[' + ws + ']+)$');
var trimRegexp = new RegExp('(^[' + ws + ']+)|([' + ws + ']+$)', 'g');
defineProperties(String.prototype, {
trim: function() {
if (this === undefined || this === null) {
Expand Down
6 changes: 6 additions & 0 deletions test/string.js
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,12 @@ var runStringTests = function() {
expect(trimmed.length).to.equal(1);
expect(trimmed).to.equal('\u0085');
});

it('should trim on both sides', function() {
var trimmed = " a ".trim();
expect(trimmed.length).to.equal(1);
expect(trimmed).to.equal('a');
});
});
});
};
Expand Down

0 comments on commit eb6ba2e

Please sign in to comment.