From df5cdf6042a19579b5d3869254cf97a2e6acf703 Mon Sep 17 00:00:00 2001 From: Jason Khanlar Date: Sun, 4 Nov 2018 20:14:00 -0500 Subject: [PATCH] Handle replacing $eye variables when the eyes are not adjacent (#43) --- lib/replacer.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/replacer.js b/lib/replacer.js index 6fa914c..cdad84c 100644 --- a/lib/replacer.js +++ b/lib/replacer.js @@ -1,5 +1,7 @@ module.exports = function (cow, variables) { var eyes = escapeRe(variables.eyes); + var eyeL = eyes.charAt(0); + var eyeR = eyes.charAt(1); var tongue = escapeRe(variables.tongue); if (cow.indexOf("$the_cow") !== -1) { @@ -11,6 +13,8 @@ module.exports = function (cow, variables) { .replace(/\$eyes/g, eyes) .replace(/\$tongue/g, tongue) .replace(/\$\{eyes\}/g, eyes) + .replace(/\$eye/, eyeL) + .replace(/\$eye/, eyeR) .replace(/\$\{tongue\}/g, tongue) ; };