1#include "EmscriptenUtilities.h"
3std::string Cogs::Core::EmscriptenUtilities::combine(
const std::string & a,
const std::string & b)
5 if (a.empty())
return b;
7 size_t contentA = a.length();
8 while (a.at(contentA -1) ==
'/' && contentA>0)
14 while (b.at(offsetB) ==
'/' && offsetB <b.length())
20 auto combined = a.back() ==
'=' ? a + b : a.substr(0, contentA) +
"/" + b.substr(offsetB, b.length()-offsetB);
21 if (combined.find(
"://") == std::string::npos)
23 replaceAll(combined,
"//",
"/");
26 replaceAll(combined,
"\\",
"/");
27 replaceAll(combined,
"\\\\",
"/");
32void Cogs::Core::EmscriptenUtilities::replaceAll(std::string & str,
const std::string & from,
const std::string & to)
34 if (from.empty())
return;
37 while ((startPos = str.find(from, startPos)) != std::string::npos) {
38 str.replace(startPos, from.length(), to);
39 startPos += to.length();