diff --git a/Makefile b/Makefile index ca9eafb3..86d1c54f 100644 --- a/Makefile +++ b/Makefile @@ -24,7 +24,8 @@ SRCS = src/main.cpp\ src/app/browser/main/tab/data/navbar/update.cpp\ src/app/browser/main/tab/label.cpp\ src/lib/database.cpp\ - src/lib/database/session.cpp + src/lib/database/session.cpp\ + src/lib/url.cpp OBJS = $(SRCS:.cpp=.o) diff --git a/po/POTFILES.in b/po/POTFILES.in index 39bfdfc9..1f5e1eb4 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -17,4 +17,5 @@ src/app/browser/main/tab/data/navbar/update.cpp src/app/browser/main/tab/label.cpp src/lib/database.cpp src/lib/database/session.cpp +src/lib/url.cpp src/main.cpp diff --git a/src/lib/url.cpp b/src/lib/url.cpp new file mode 100644 index 00000000..fd50ebf3 --- /dev/null +++ b/src/lib/url.cpp @@ -0,0 +1,28 @@ +#include "url.hpp" + +using namespace lib; +using namespace std; + +Url::Url( + string subject +) { + smatch results; + + static const regex pattern( // @TODO user:password@#fragment? + R"regex(^(\w+)://([^:\/]+):?(\d+)?\/?([^\?]+)?\??(.*)?$)regex" + ); + + regex_search( + subject, + results, + pattern + ); + + scheme = results[1]; + host = results[2]; + port = results[3]; + path = results[4]; + query = results[5]; +} + +Url::~Url() = default; \ No newline at end of file diff --git a/src/lib/url.hpp b/src/lib/url.hpp new file mode 100644 index 00000000..d7756108 --- /dev/null +++ b/src/lib/url.hpp @@ -0,0 +1,27 @@ +#ifndef LIB_URL_HPP +#define LIB_URL_HPP + +#include +#include + +namespace lib +{ + class Url + { + public: + + std::string scheme, + host, + port, + path, + query; + + Url( + std::string subject + ); + + ~Url(); + }; +} + +#endif // LIB_URL_HPP \ No newline at end of file