Skip to content

armgit / mocha

Public Imported from GitHub
0

☕️ Classic, reliable, trusted test framework for Node.js and the browser

Use global replace regex

Cory Thomas694735807def
diff --git a/lib/reporters/teamcity.js b/lib/reporters/teamcity.js
index a8632238..fab35092 100644
--- a/lib/reporters/teamcity.js
+++ b/lib/reporters/teamcity.js
@@ -52,13 +52,13 @@ function Teamcity(runner) {
*/
function escape(str) {
- return str.replace("|", "||")
- .replace("\n", "|n")
- .replace("\r", "|r")
- .replace("[", "|[")
- .replace("]", "|]")
- .replace("\u0085", "|x")
- .replace("\u2028", "|l")
- .replace("\u2029", "|p")
+ return str.replace(/|/g, "||")
+ .replace(/\n/g, "|n")
+ .replace(/\r/g, "|r")
+ .replace(/\[/g, "|[")
+ .replace(/\]/g, "|]")
+ .replace(/\u0085/g, "|x")
+ .replace(/\u2028/g, "|l")
+ .replace(/\u2029/g, "|p")
.replace(/'/g, "|'");
}