nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: alexa-js/alexa-app
Pull request #371 (2018-10-05 20:35:00)

Call response.prepare() after post()
Fixing issue #224 


Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index ca26ad9..a0501e0 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,6 +6,7 @@
 * [#352](https://github.com/alexa-js/alexa-app/pull/352): Allow utterance expansion in custom slot type synonyms - [@daanzu](https://github.com/daanzu).
 * [#361](https://github.com/alexa-js/alexa-app/pull/361): Fix object reference for dialogState in in doc - [@Sephtenen](https://github.com/Sephtenen).
 * [#364](https://github.com/alexa-js/alexa-app/pull/364): Fix reprompt() to concatenate multiple SSML prompts - [@andrewjhunt](https://github.com/andrewjhunt).
+* [#371](https://github.com/alexa-js/alexa-app/pull/371): Call response.prepare() after post() - [@fremail](https://github.com/fremail).
 * Your contribution here.
 
 ### 4.2.2 (April 7, 2018)
diff --git a/index.js b/index.js
index 297d19a..26b7fb1 100644
--- a/index.js
+++ b/index.js
@@ -543,6 +543,7 @@ alexa.app = function(name) {
         postPromise = Promise.resolve(self.post(request, response, requestType, exception));
       }
       return postPromise.then(function() {
+        response.prepare();
         if (!response.resolved) {
           response.resolved = true;
         }
@@ -557,6 +558,7 @@ alexa.app = function(name) {
         postPromise = Promise.resolve(self.post(request, response, requestType, exception));
       }
       return postPromise.then(function() {
+        response.prepare();
         if (!response.resolved) {
           response.resolved = true;
           throw msg;


Test patch:
diff --git a/test/test_alexa_app_session.js b/test/test_alexa_app_session.js
index a24a172..72a143a 100644
--- a/test/test_alexa_app_session.js
+++ b/test/test_alexa_app_session.js
@@ -572,5 +572,31 @@ describe("Alexa", function() {
         ]);
       });
     });
+
+    describe("update session in post()", function() {
+      var mockRequest = mockHelper.load("intent_request_malformed_session.json");
+
+      it("responds with updated session object", function() {
+        testApp.pre = function(req) {
+          if (req.hasSession()) {
+            req.getSession().set("foo", "bar");
+          }
+        };
+        testApp.post = function(req) {
+          if (req.hasSession()) {
+            req.getSession().set("foo", "big_bar");
+          }
+        };
+        var subject = testApp.request(mockRequest).then(function(response) {
+          return response.sessionAttributes;
+        });
+
+        return Promise.all([
+          expect(subject).to.eventually.become({
+            "foo": "big_bar"
+          })
+        ]);
+      });
+    });
   });
 });
Repository: alexa-js/alexa-app
Pull request #373 (2018-10-14 20:13:43)

Keep multiple newlines in card output (Continue PR #83)
See PR #83 (2 years old hehe)

I merged the changes to current code and added tests.


Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index a0501e0..ca8bffc 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,6 +7,7 @@
 * [#361](https://github.com/alexa-js/alexa-app/pull/361): Fix object reference for dialogState in in doc - [@Sephtenen](https://github.com/Sephtenen).
 * [#364](https://github.com/alexa-js/alexa-app/pull/364): Fix reprompt() to concatenate multiple SSML prompts - [@andrewjhunt](https://github.com/andrewjhunt).
 * [#371](https://github.com/alexa-js/alexa-app/pull/371): Call response.prepare() after post() - [@fremail](https://github.com/fremail).
+* [#373](https://github.com/alexa-js/alexa-app/pull/373): Keep multiple newlines in card output - [@kielni](https://github.com/kielni) and [@fremail](https://github.com/fremail).
 * Your contribution here.
 
 ### 4.2.2 (April 7, 2018)
diff --git a/lib/to-ssml.js b/lib/to-ssml.js
index afa506c..f5b3a02 100644
--- a/lib/to-ssml.js
+++ b/lib/to-ssml.js
@@ -32,7 +32,7 @@ var ssml = {
   cleanse: function(str) {
     // <p> is left in place to support intended HTML output
     return str.replace(/<\/?(speak|break|phoneme|audio|say-as|s\b|w\b)[^>]*>/gi, "")
-      .replace(/\s*\n\s*/g, "\n")
+      .replace(/[\r\t\f\v ]*\n[\r\t\f\v ]*/g, "\n")
       .replace(/  +/g, " ")
       .replace(/ ([,!?;:])/g, "$1")
       .trim();


Test patch:
diff --git a/test/test_ssml.js b/test/test_ssml.js
index 0ae4436..b05f9e8 100644
--- a/test/test_ssml.js
+++ b/test/test_ssml.js
@@ -161,6 +161,20 @@ describe('SSML', function() {
           return SSML.cleanse(input).should.equal(expectedOutput);
         });
 
+        it('should not truncate multiple line breaks', function() {
+          var input = 'First line\n\nSecond line';
+          var expectedOutput = 'First line\n\nSecond line';
+
+          return SSML.cleanse(input).should.equal(expectedOutput);
+        });
+
+        it('but should truncate whitespaces and tabs around line breaks', function() {
+          var input = 'First line \n\t \n Second line';
+          var expectedOutput = 'First line\n\nSecond line';
+
+          return SSML.cleanse(input).should.equal(expectedOutput);
+        });
+
       });
     });
   });