summaryrefslogtreecommitdiff
path: root/src/net/Url.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/net/Url.cpp')
-rw-r--r--src/net/Url.cpp88
1 files changed, 44 insertions, 44 deletions
diff --git a/src/net/Url.cpp b/src/net/Url.cpp
index 005506c..1c7aae6 100644
--- a/src/net/Url.cpp
+++ b/src/net/Url.cpp
@@ -29,52 +29,52 @@ using namespace std;
namespace TgBot {
Url::Url(const string& url) {
- bool isProtocolParsed = false;
- bool isHostParsed = false;
- bool isPathParsed = false;
- bool isQueryParsed = false;
+ bool isProtocolParsed = false;
+ bool isHostParsed = false;
+ bool isPathParsed = false;
+ bool isQueryParsed = false;
- for (size_t i = 0, count = url.length(); i < count; ++i) {
- char c = url[i];
+ for (size_t i = 0, count = url.length(); i < count; ++i) {
+ char c = url[i];
- if (!isProtocolParsed) {
- if (c == ':') {
- isProtocolParsed = true;
- i += 2;
- } else {
- protocol += c;
- }
- } else if (!isHostParsed) {
- if (c == '/') {
- isHostParsed = true;
- path += '/';
- } else if (c == '?') {
- isHostParsed = isPathParsed = true;
- path += '/';
- } else if (c == '#') {
- isHostParsed = isPathParsed = isQueryParsed = true;
- path += '/';
- } else {
- host += c;
- }
- } else if (!isPathParsed) {
- if (c == '?') {
- isPathParsed = true;
- } else if (c == '#') {
- isPathParsed = isQueryParsed = true;
- } else {
- path += c;
- }
- } else if (!isQueryParsed) {
- if (c == '#') {
- isQueryParsed = true;
- } else {
- query += c;
- }
- } else {
- fragment += c;
- }
- }
+ if (!isProtocolParsed) {
+ if (c == ':') {
+ isProtocolParsed = true;
+ i += 2;
+ } else {
+ protocol += c;
+ }
+ } else if (!isHostParsed) {
+ if (c == '/') {
+ isHostParsed = true;
+ path += '/';
+ } else if (c == '?') {
+ isHostParsed = isPathParsed = true;
+ path += '/';
+ } else if (c == '#') {
+ isHostParsed = isPathParsed = isQueryParsed = true;
+ path += '/';
+ } else {
+ host += c;
+ }
+ } else if (!isPathParsed) {
+ if (c == '?') {
+ isPathParsed = true;
+ } else if (c == '#') {
+ isPathParsed = isQueryParsed = true;
+ } else {
+ path += c;
+ }
+ } else if (!isQueryParsed) {
+ if (c == '#') {
+ isQueryParsed = true;
+ } else {
+ query += c;
+ }
+ } else {
+ fragment += c;
+ }
+ }
}
}