static std::string joinUrls()

in src/HTMLViewer.cpp [46:58]


static std::string joinUrls(std::string u1, std::string const& u2) {
  if (startsWith(u2, "/")) return u2;
  while (!u1.empty() && u1.back() != '/') u1.pop_back();
  if (u1.empty()) u1 = "/";
  for (int i = 0; true; i += 3) {
    if (u2.substr(i, 3) == "../") {
      do u1.pop_back(); while (!u1.empty() && u1.back() != '/');
      if (u1.empty()) u1 = "/";
    } else {
      return u1 + u2.substr(i);
    }
  }
}