From f9520362c9759a3e18bd123a331d0708bb7235de Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Sun, 18 May 2014 12:35:22 -0700 Subject: [PATCH] Use match rather than split --- js/id/ui/raw_tag_editor.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/js/id/ui/raw_tag_editor.js b/js/id/ui/raw_tag_editor.js index 17645406c..22b795bc3 100644 --- a/js/id/ui/raw_tag_editor.js +++ b/js/id/ui/raw_tag_editor.js @@ -167,9 +167,9 @@ iD.ui.RawTagEditor = function(context) { tag = {}; if (kNew && kNew !== kOld) { - var a = _.compact(kNew.split(/^(.*)_(\d+)$/)), - base = a[0], - suffix = (a.length > 1) ? parseInt(a[1]): 1; + var match = kNew.match(/^(.*?)(?:_(\d+))?$/), + base = match[1], + suffix = +(match[2] || 1); while (tags[kNew]) { // rename key if already in use kNew = base + '_' + suffix++; }