Skip to content
Snippets Groups Projects
Commit efb89761 authored by Adrien Béraud's avatar Adrien Béraud Committed by Adrien Béraud
Browse files

namedirectory: add default scheme, use canonical name

Change-Id: Ia2858d7dab79954312b657ea4380f0ea65bfa640
parent 3e586b0d
No related branches found
No related tags found
No related merge requests found
...@@ -122,10 +122,19 @@ NameDirectory::load() ...@@ -122,10 +122,19 @@ NameDirectory::load()
loadCache(); loadCache();
} }
std::string
canonicalName(const std::string& url) {
std::string name = url;
std::transform(name.begin(), name.end(), name.begin(), ::tolower);
if (name.find("://") == std::string::npos)
name = "https://" + name;
return name;
}
NameDirectory& NameDirectory&
NameDirectory::instance(const std::string& serverUrl, std::shared_ptr<dht::Logger> l) NameDirectory::instance(const std::string& serverUrl, std::shared_ptr<dht::Logger> l)
{ {
const std::string& s = serverUrl.empty() ? DEFAULT_SERVER_HOST : serverUrl; const std::string& s = serverUrl.empty() ? DEFAULT_SERVER_HOST : canonicalName(serverUrl);
static std::mutex instanceMtx {}; static std::mutex instanceMtx {};
std::lock_guard lock(instanceMtx); std::lock_guard lock(instanceMtx);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment