about summary refs log tree commit diff
path: root/app/lib/command_tag/processor.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/lib/command_tag/processor.rb')
-rw-r--r--app/lib/command_tag/processor.rb17
1 files changed, 8 insertions, 9 deletions
diff --git a/app/lib/command_tag/processor.rb b/app/lib/command_tag/processor.rb
index 8461e902f..6bc9a9b97 100644
--- a/app/lib/command_tag/processor.rb
+++ b/app/lib/command_tag/processor.rb
@@ -137,16 +137,15 @@ class CommandTag::Processor
           end
         end
 
-        index_start = to_integer(parts[1])
-        index_end   = to_integer(parts[2])
+        index       = to_integer(parts[1])
+        str_start   = to_integer(parts[2])
+        str_end     = to_integer(parts[3])
 
-        if ['all', '[]'].include?(parts[1])
-          var(name).join(separator)
-        elsif index_end.zero?
-          var(name)[index_start].presence || ''
-        else
-          var(name)[index_start..index_end].presence || ''
-        end
+        str_start, str_end = [str_end, str_start] if str_start > str_end
+
+        value = (['all', '[]'].include?(parts[1]) ? var(name).join(separator) : var(name)[index].to_s)
+
+        (str_end - str_start).zero? ? value : value[str_start..str_end]
       end
     end.rstrip
   end