Fixed path separators in diagram link URL's in Windows

This commit is contained in:
Bartek Kryza
2023-01-11 00:29:43 +01:00
parent c7d201eef9
commit 3fbf3da27f
4 changed files with 51 additions and 1 deletions

View File

@@ -303,4 +303,20 @@ std::size_t hash_seed(std::size_t seed)
return kSeedStart + (seed << kSeedShiftFirst) + (seed >> kSeedShiftSecond);
}
std::string path_to_url(const std::filesystem::path& p) {
std::vector<std::string> path_tokens;
auto it = p.begin();
if(p.has_root_directory())
it++;
for(; it != p.end(); it++)
path_tokens.push_back(it->string());
if(p.has_root_directory())
return fmt::format("/{}", fmt::join(path_tokens, "/"));
else
return fmt::format("{}", fmt::join(path_tokens, "/"));
}
} // namespace clanguml::util