Repository: xbmc/xbmc
File: xbmc/utils/URIUtils.cpp (C++)

Code before:
  if (StringUtils::EqualsNoCase(parentFolder, "VIDEO_TS") ||
      StringUtils::EqualsNoCase(parentFolder, "BDMV"))
    return GetParentPath(parent); // go back up another one
  return parent;
}

std::string URIUtils::GetDiscBasePath(const std::string& file)
{
  std::string base{GetDiscBase(file)};
  if (IsDiscImage(base))
    return GetDirectory(base);
  return base;
}

std::string URIUtils::GetBlurayFile(const std::string& path)
{
  if (IsBlurayPath(path))
  {
    const CURL url(path);
    const CURL url2(url.GetHostName()); // strip bluray://
    if (url2.IsProtocol("udf"))
      // ISO
      return url2.GetHostName(); // strip udf://
    if (url.IsProtocol("bluray"))
      // BDMV
      return url2.Get() + "BDMV/index.bdmv";
  }
  return "";
}

std::string URLEncodePath(const std::string& strPath)
{
  std::vector<std::string> segments = StringUtils::Split(strPath, "/");
  for (std::vector<std::string>::iterator i = segments.begin(); i != segments.end(); ++i)
    *i = CURL::Encode(*i);

  return StringUtils::Join(segments, "/");
}

std::string URLDecodePath(const std::string& strPath)
{
  std::vector<std::string> segments = StringUtils::Split(strPath, "/");
  for (std::vector<std::string>::iterator i = segments.begin(); i != segments.end(); ++i)
    *i = CURL::Decode(*i);

  return StringUtils::Join(segments, "/");
}

std::string URIUtils::ChangeBasePath(const std::string &fromPath, const std::string &fromFile, const std::string &toPath, const bool &bAddPath /* = true */)
{
  std::string toFile = fromFile;

Review comment (suggestion):
I know this was existing code, but please use `URIUtils::AddFileToFolder()` to join paths, e.g. `URIUtils::AddFileToFolder(url2.Get(), "BDMV", "index.bdmv")`

Code after:
  if (StringUtils::EqualsNoCase(parentFolder, "VIDEO_TS") ||
      StringUtils::EqualsNoCase(parentFolder, "BDMV"))
    return GetParentPath(parent); // go back up another one
  return parent;
}

std::string URIUtils::GetDiscBasePath(const std::string& file)
{
  std::string base{GetDiscBase(file)};
  if (IsDiscImage(base))
    return GetDirectory(base);
  return base;
}

std::string URIUtils::GetBlurayFile(const std::string& path)
{
  if (IsBlurayPath(path))
  {
    const CURL url(path);
    const CURL url2(url.GetHostName()); // strip bluray://
    if (url2.IsProtocol("udf"))
      // ISO
      return url2.GetHostName(); // strip udf://
    return AddFileToFolder(url2.Get(), "BDMV", "index.bdmv"); // BDMV
  }
  return std::string{};
}

std::string URLEncodePath(const std::string& strPath)
{
  std::vector<std::string> segments = StringUtils::Split(strPath, "/");
  for (std::vector<std::string>::iterator i = segments.begin(); i != segments.end(); ++i)
    *i = CURL::Encode(*i);

  return StringUtils::Join(segments, "/");
}

std::string URLDecodePath(const std::string& strPath)
{
  std::vector<std::string> segments = StringUtils::Split(strPath, "/");
  for (std::vector<std::string>::iterator i = segments.begin(); i != segments.end(); ++i)
    *i = CURL::Decode(*i);

  return StringUtils::Join(segments, "/");
}

std::string URIUtils::ChangeBasePath(const std::string &fromPath, const std::string &fromFile, const std::string &toPath, const bool &bAddPath /* = true */)
{
  std::string toFile = fromFile;

  // Convert back slashes to forward slashes, if required