diff --git a/lsp-server/src/provider/initialize/initialize.cpp b/lsp-server/src/provider/initialize/initialize.cpp index dd62cab..753f785 100644 --- a/lsp-server/src/provider/initialize/initialize.cpp +++ b/lsp-server/src/provider/initialize/initialize.cpp @@ -130,6 +130,30 @@ namespace lsp::provider spdlog::info("Initiated loading for {} workspace folder(s)", workspace_folders.size()); } + std::string UriDecode(const std::string& encoded) + { + std::string decoded; + for (size_t i = 0; i < encoded.length(); ++i) + { + if (encoded[i] == '%' && i + 2 < encoded.length()) + { + std::string hex = encoded.substr(i + 1, 2); + char ch = static_cast(std::stoi(hex, nullptr, 16)); + decoded += ch; + i += 2; + } + else if (encoded[i] == '+') + { + decoded += ' '; + } + else + { + decoded += encoded[i]; + } + } + return decoded; + } + std::string Initialize::UriToPath(const protocol::DocumentUri& uri) { std::string path = uri; @@ -139,6 +163,7 @@ namespace lsp::provider if (path.length() > 0 && path[0] == '/') path = path.substr(1); #endif + path = UriDecode(path); return path; } }