Skip to content

Commit 20d0bb2

Browse files
committed
Added extractURLProtocol
1 parent be5fde0 commit 20d0bb2

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/wsjcpp_core.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <streambuf>
1919
#include <sys/types.h>
2020
#include <sys/socket.h>
21+
#include <arpa/inet.h>
2122

2223
// ---------------------------------------------------------------------
2324

@@ -434,6 +435,18 @@ std::string WSJCppCore::getPointerAsHex(void *p) {
434435
return "0x" + std::string(stream.str());
435436
}
436437

438+
// ---------------------------------------------------------------------
439+
440+
std::string WSJCppCore::extractURLProtocol(const std::string& sValue) {
441+
std::string sRet = "";
442+
int nPosProtocol = sValue.find("://");
443+
if (nPosProtocol == std::string::npos) {
444+
return sRet;
445+
}
446+
sRet = sValue.substr(0, nPosProtocol);
447+
return sRet;
448+
}
449+
437450
// ---------------------------------------------------------------------
438451
// WSJCppLog
439452

src/wsjcpp_core.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ class WSJCppCore {
5252

5353
static unsigned long convertVoidToULong(void *p);
5454
static std::string getPointerAsHex(void *p);
55+
static std::string extractURLProtocol(const std::string& sValue);
5556
};
5657

5758

0 commit comments

Comments
 (0)