mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-02 17:45:28 +00:00
draft url parser lib
This commit is contained in:
parent
fcd1898f4a
commit
83def8fb85
4 changed files with 58 additions and 1 deletions
3
Makefile
3
Makefile
|
|
@ -24,7 +24,8 @@ SRCS = src/main.cpp\
|
||||||
src/app/browser/main/tab/data/navbar/update.cpp\
|
src/app/browser/main/tab/data/navbar/update.cpp\
|
||||||
src/app/browser/main/tab/label.cpp\
|
src/app/browser/main/tab/label.cpp\
|
||||||
src/lib/database.cpp\
|
src/lib/database.cpp\
|
||||||
src/lib/database/session.cpp
|
src/lib/database/session.cpp\
|
||||||
|
src/lib/url.cpp
|
||||||
|
|
||||||
OBJS = $(SRCS:.cpp=.o)
|
OBJS = $(SRCS:.cpp=.o)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,4 +17,5 @@ src/app/browser/main/tab/data/navbar/update.cpp
|
||||||
src/app/browser/main/tab/label.cpp
|
src/app/browser/main/tab/label.cpp
|
||||||
src/lib/database.cpp
|
src/lib/database.cpp
|
||||||
src/lib/database/session.cpp
|
src/lib/database/session.cpp
|
||||||
|
src/lib/url.cpp
|
||||||
src/main.cpp
|
src/main.cpp
|
||||||
|
|
|
||||||
28
src/lib/url.cpp
Normal file
28
src/lib/url.cpp
Normal file
|
|
@ -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;
|
||||||
27
src/lib/url.hpp
Normal file
27
src/lib/url.hpp
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
#ifndef LIB_URL_HPP
|
||||||
|
#define LIB_URL_HPP
|
||||||
|
|
||||||
|
#include <regex>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
namespace lib
|
||||||
|
{
|
||||||
|
class Url
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
std::string scheme,
|
||||||
|
host,
|
||||||
|
port,
|
||||||
|
path,
|
||||||
|
query;
|
||||||
|
|
||||||
|
Url(
|
||||||
|
std::string subject
|
||||||
|
);
|
||||||
|
|
||||||
|
~Url();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // LIB_URL_HPP
|
||||||
Loading…
Add table
Add a link
Reference in a new issue