Permalink
Browse files

Update ssml.cleanse to stop removing spaces before decimals (#236)

* Update ssml.cleanse to stop removing spaces before decimals (i.e. “.2oz, .5oz, .25oz” > “.2oz,.5oz,.25oz”)

* Update CHANGELOG

* Replace speak/break/etc tags with nothing instead of a space

* Add test to prevent regression regarding truncation of spaces before periods
  • Loading branch information...
1 parent 498f6f9 commit f1d068dea3f4fba2e14a5e1dbe1f4b6bf400c44e @aminimalanimal aminimalanimal committed with dblock May 9, 2017
Showing with 10 additions and 2 deletions.
  1. +1 −0 CHANGELOG.md
  2. +2 −2 lib/to-ssml.js
  3. +7 −0 test/test_ssml.js
View
@@ -2,6 +2,7 @@
### 4.0.1 (Next)
+* [#236](https://github.com/alexa-js/alexa-app/pull/236): Update `ssml.cleanse` to stop removing spaces before decimals - [@aminimalanimal](https://github.com/aminimalanimal).
* [#215](https://github.com/alexa-js/alexa-app/pull/215): Fixed `session.details` to match with session in the request object - [@danielstieber](https://github.com/danielstieber).
* [#223](https://github.com/alexa-js/alexa-app/issues/223): Added support for `AskForPermissionsConsent` cards - [@ericblade](https://github.com/ericblade).
* [#219](https://github.com/alexa-js/alexa-app/pull/219): Preserve session when clearing non-existent attribute - [@adrianba](https://github.com/adrianba).
View
@@ -31,10 +31,10 @@ 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, " ")
+ return str.replace(/<\/?(speak|break|phoneme|audio|say-as|s\b|w\b)[^>]*>/gi, "")
.replace(/\s*\n\s*/g, "\n")
.replace(/ +/g, " ")
- .replace(/ ([.,!?;:])/g, "$1")
+ .replace(/ ([,!?;:])/g, "$1")
.trim();
}
};
View
@@ -154,6 +154,13 @@ describe('SSML', function() {
return SSML.cleanse(input).should.equal(expectedOutput);
});
+ it('should not truncate spaces before periods', function() {
+ var input = '.1, .2, and .3';
+ var expectedOutput = '.1, .2, and .3';
+
+ return SSML.cleanse(input).should.equal(expectedOutput);
+ });
+
});
});
});

0 comments on commit f1d068d

Please sign in to comment.