Skip to content

Commit

Permalink
Allow non-formatting tokens to include newlines. Fixes moment#1151
Browse files Browse the repository at this point in the history
  • Loading branch information
icambron committed Oct 2, 2013
1 parent ee0f1a3 commit 9525c3c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion moment.js
Expand Up @@ -684,7 +684,7 @@


function removeFormattingTokens(input) {
if (input.match(/\[.*\]/)) {
if (input.match(/\[[\s\S]/)) {
return input.replace(/^\[|\]$/g, "");
}
return input.replace(/\\/g, "");
Expand Down
3 changes: 2 additions & 1 deletion test/moment/format.js
Expand Up @@ -10,7 +10,7 @@ exports.format = {
},

"format escape brackets" : function (test) {
test.expect(9);
test.expect(10);

moment.lang('en');

Expand All @@ -24,6 +24,7 @@ exports.format = {
test.equal(b.format('[L] L'), 'L 02/14/2009', 'localized tokens with escaped localized tokens');
test.equal(b.format('[L LL LLL LLLL aLa]'), 'L LL LLL LLLL aLa', 'localized tokens with escaped localized tokens');
test.equal(b.format('[LLL] LLL'), 'LLL February 14 2009 3:25 PM', 'localized tokens with escaped localized tokens (recursion)');
test.equal(b.format('YYYY[\n]DD[\n]'), '2009\n14\n', 'Newlines');
test.done();
},

Expand Down

0 comments on commit 9525c3c

Please sign in to comment.