From 2353486150c88225a4218c12260d6182876585d6 Mon Sep 17 00:00:00 2001 From: Skylar Grant Date: Mon, 8 May 2023 08:59:51 -0400 Subject: [PATCH] Fix for hypens in tree name --- modules/functions.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/modules/functions.js b/modules/functions.js index 8016b44..2be6dee 100755 --- a/modules/functions.js +++ b/modules/functions.js @@ -539,7 +539,19 @@ const functions = { hasPin: 0 } // Break the line into parts separated by a hyphen - - const parts = line.split(" - "); + // DO NOT USE this, it breaks when any tree name contains " - " which + // isn't uncommon apparently + // const parts = line.split(" - "); + + // Instead, find the indices of the first and last instances of " - " + const hyphenIndices = [line.indexOf(" - "), line.lastIndexOf(" - ")]; + const parts = [ + line.slice(0, hyphenIndices[0]), + line.slice(hyphenIndices[0] + 3, hyphenIndices[1]), + line.slice(hyphenIndices[1] + 3, line.length) + ]; + + // // Grab the rank // Preset the indices to split the lines to get the data