Skip to content

Commit

Permalink
fix url parser to correctly handle unix domain sockets
Browse files Browse the repository at this point in the history
  • Loading branch information
MP91 committed Nov 18, 2024
1 parent 216a7f2 commit e710548
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,6 @@ conan_imports_manifest.txt
# auto-generated SDK version
version.txt
logs

# Velocitas home
.velocitas
6 changes: 6 additions & 0 deletions sdk/src/sdk/Utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ SimpleUrlParse::SimpleUrlParse(const std::string& url) {
schemeLen = 0;
}

// return the full URL if using Unix domain socket
if (m_scheme == "unix") {
m_netLocation = url;
return;
}

auto startOfSchemePart = url.find(SCHEME_PART_START, schemeLen);
if (startOfSchemePart != std::string::npos) {
startOfSchemePart += SCHEME_PART_START.length();
Expand Down
5 changes: 5 additions & 0 deletions sdk/tests/unit/Utils_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,3 +121,8 @@ TEST(SimpleUrlParse, ctor_someScheme_slashes_ipAddress_noPort_pathAndQuery) {
EXPECT_EQ("somescheme", cut.getScheme());
EXPECT_EQ("1.2.3.4", cut.getNetLocation());
}
TEST(SimpleUrlParse, ctor_unix_domain_socket) {
SimpleUrlParse cut("unix:///some/path/to/socket");
EXPECT_EQ("unix", cut.getScheme());
EXPECT_EQ("unix:///some/path/to/socket", cut.getNetLocation());
}

0 comments on commit e710548

Please sign in to comment.