]> git.ipfire.org Git - thirdparty/moment.git/commitdiff
Allow non-formatting tokens to include newlines. Fixes #1151 1158/head
authorIsaac Cambron <isaac@isaaccambron.com>
Wed, 2 Oct 2013 15:19:31 +0000 (11:19 -0400)
committerIsaac Cambron <isaac@isaaccambron.com>
Wed, 2 Oct 2013 15:19:31 +0000 (11:19 -0400)
moment.js
test/moment/format.js

index 8957b5188fa2d7fe42075ef77d312e5811623805..3209dd9bb743915dd57803b76c4435f6b9afd234 100644 (file)
--- a/moment.js
+++ b/moment.js
 
 
     function removeFormattingTokens(input) {
-        if (input.match(/\[.*\]/)) {
+        if (input.match(/\[[\s\S]/)) {
             return input.replace(/^\[|\]$/g, "");
         }
         return input.replace(/\\/g, "");
index bf1e32f917ac77dd55fba99422e829722b2ea635..512e821ab79623e43050b0a2824e749c9a384c2c 100644 (file)
@@ -10,7 +10,7 @@ exports.format = {
     },
 
     "format escape brackets" : function (test) {
-        test.expect(9);
+        test.expect(10);
 
         moment.lang('en');
 
@@ -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();
     },