I've gained interest in C++ and lacked the idea of a project, so I thought I'd start out with a port
of the urlparse lib from Python. The functionality is pretty simple, I'll list the methods and their purpose below.
Library contentsParseResult UrlParse::parse(string url)
Returns a ParseResult object, it contains multiple parts, the names of these
parts are: scheme, netloc, path, query and fragment.
An example program:
[gist]Daxda/54b543947916d5192fe5[/gist]
The output:
Scheme: https
Netloc: evilzone.org
Path: /le/path/page.php
Query: id=1&evil=1
Fragment: important
string ParseResult::getUrl()
string UrlParse::getUrl(ParseResult parsed_url)
Expands the parsed URL, an example of it's usage:
[gist]Daxda/2eb81d6c3dac78c4036e[/gist]
The output:
https://evilzone.org/le/path/page.php?id=1&evil=1#important https://evilzone.org/le/path/page.php?id=1&evil=1#importantstring UrlParse::join(string url, string location)
This method joins an URL with the specified location, an example of it looks like this:
[gist]Daxda/743e51c4d970d9c6019d[/gist]
output,
https://evilzone.org/level1/level3/page.phpvoid UrlParse::defrag(string url, string &new_url, string &fragment)
Splits the URL at the fragment indicator (#) into two strings, new_url and fragment.
Example program:
[gist]Daxda/3845fbdd30538cb32e0b[/gist]
Output of the program:
Our URL without fragment:
https://evilzone.org/page.php?evil=1 The removed fragment: overview
DownloadObtain the full source of the libs and an example program from
my Github repoFeedback and critiquePlease provide constructive feedback and critique if you have any, I do my best to improve my code and
I'd love to get multiple opinions about this project.