a27a5ae (parent a2d9c67)7/25/2016, 3:54:27 PM
code indentation
+ 19
- 20
app/helpers/string.js
@@ -1,24 +1,23 @@
 (function () {
-/**
-* HTML escaping.
-**/
-String.prototype.escape = function() {
-  var tagsToReplace = {
-    '&': '&',
-    '<': '&lt;',
-    '>': '&gt;'
+  /**
+  * HTML escaping.
+  **/
+  String.prototype.escape = function() {
+    var tagsToReplace = {
+      '&': '&amp;',
+      '<': '&lt;',
+      '>': '&gt;'
+    };
+    return this.replace(/[&<>]/g, function(tag) {
+      return tagsToReplace[tag] || tag;
+    });
   };
-  return this.replace(/[&<>]/g, function(tag) {
-    return tagsToReplace[tag] || tag;
-  });
-};
-
-/**
-* Newline (\r\n) to <br> or <br/> if xhtml.
-**/
-String.prototype.nl2br = function (is_xhtml) {
-  var breakTag = (is_xhtml || typeof is_xhtml === 'undefined') ? '<br ' + '/>' : '<br>';
-  return this.replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, '$1' + breakTag + '$2');
-};
 
+  /**
+  * Newline (\r\n) to <br> or <br/> if xhtml.
+  **/
+  String.prototype.nl2br = function (is_xhtml) {
+    var breakTag = (is_xhtml || typeof is_xhtml === 'undefined') ? '<br ' + '/>' : '<br>';
+    return this.replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, '$1' + breakTag + '$2');
+  };
 })();