From d73daf52b3e8e1c32b37084e3093ec15e404abd7 Mon Sep 17 00:00:00 2001 From: Shawn Allen Date: Mon, 22 Jul 2019 16:43:45 -0700 Subject: [PATCH] be smarter in replaceAll() --- lib/erb-to-html.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/lib/erb-to-html.js b/lib/erb-to-html.js index d5c24d63..2776e59c 100644 --- a/lib/erb-to-html.js +++ b/lib/erb-to-html.js @@ -49,8 +49,8 @@ function converter({converters = {}}) { const parts = argString.split(/, */) const args = [] const kwargs = {} + let match for (const part of parts) { - let match if ((match = part.match(/^:(.+) => (.+)$/))) { kwargs[unquote(match[1])] = unquote(match[2]) } else if ((match = part.match(/^(.+): (.+)$/))) { @@ -73,11 +73,7 @@ function converter({converters = {}}) { } function replaceAll(str, input, output) { - let result = str - while (result.includes(input)) { - result = result.replace(input, output) - } - return result + return str.split(input).join(output) } function unquote(str) {