mirror of
https://github.com/YGGverse/Yoda.git
synced 2025-01-29 20:44:25 +00:00
draft url parser lib
This commit is contained in:
parent
fcd1898f4a
commit
83def8fb85
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/label.cpp\
|
||||
src/lib/database.cpp\
|
||||
src/lib/database/session.cpp
|
||||
src/lib/database/session.cpp\
|
||||
src/lib/url.cpp
|
||||
|
||||
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/lib/database.cpp
|
||||
src/lib/database/session.cpp
|
||||
src/lib/url.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…
x
Reference in New Issue
Block a user