class ChefConfig::PathHelper

def self.join(*args, windows: ChefUtils.windows?)

def self.join(*args, windows: ChefUtils.windows?)
  path_separator_regex = Regexp.escape(windows ? "#{File::SEPARATOR}#{BACKSLASH}" : File::SEPARATOR)
  trailing_slashes_regex = /[#{path_separator_regex}]+$/.freeze
  leading_slashes_regex = /^[#{path_separator_regex}]+/.freeze
  args.flatten.inject do |joined_path, component|
    joined_path = joined_path.sub(trailing_slashes_regex, "")
    component = component.sub(leading_slashes_regex, "")
    joined_path + "#{path_separator(windows: windows)}#{component}"
  end
end