Fixed a couple edge cases with Task#normalize_path causing failures

This commit is contained in:
2025-10-31 11:53:53 -05:00
parent ce10cdc658
commit b299593076
2 changed files with 7 additions and 4 deletions

View File

@@ -117,6 +117,7 @@ class W3DHub
return "#{base_path}/#{path}" if W3DHub.windows? # Windows is easy, or annoying, depending how you look at it...
constructed_path = base_path
lowercase_full_path = "#{base_path}/#{path}".downcase.strip.freeze
accepted_parts = 0
split_path = path.split("/")
@@ -124,15 +125,17 @@ class W3DHub
Dir.glob("#{constructed_path}/*").each do |part|
next unless "#{constructed_path}/#{segment}".downcase == part.downcase
# Handle edge case where a file with the same name is in a higher directory
next if File.file?(part) && part.downcase.strip != lowercase_full_path
constructed_path = part
accepted_parts += 1
break if File.file?(constructed_path)
break
end
end
# Find file if it exists else use provided path as cased
if "#{base_path}/#{path}".length == constructed_path.length
if constructed_path.downcase.strip == lowercase_full_path
constructed_path
elsif accepted_parts.positive?
"#{constructed_path}/#{split_path[accepted_parts..].join('/')}"

View File

@@ -53,4 +53,4 @@ class W3DHub
end
end
end
end
end