From e53641add1d67b9a9c1260203cd217f3bcfa449c Mon Sep 17 00:00:00 2001 From: Alex Ling Date: Tue, 9 Jun 2020 09:42:28 +0000 Subject: [PATCH] Handle the rare case when renamed string is ".." --- src/rename.cr | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/rename.cr b/src/rename.cr index cd6af7b7..59fd6457 100644 --- a/src/rename.cr +++ b/src/rename.cr @@ -129,15 +129,19 @@ module Rename end def render(hash : VHash) - @ary.map do |e| + str = @ary.map do |e| if e.is_a? String e else e.render hash end - end.join - .strip - .gsub("/", "_") + end.join.strip + post_process str + end + + private def post_process(str) + return "_" if str == ".." + str.gsub "/", "_" end end end