https://github.com/malwarebo/slice
C++ header only URL parser
https://github.com/malwarebo/slice
cpp
Last synced: 23 days ago
JSON representation
C++ header only URL parser
- Host: GitHub
- URL: https://github.com/malwarebo/slice
- Owner: malwarebo
- Created: 2023-08-02T12:58:36.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2023-09-21T16:48:56.000Z (over 2 years ago)
- Last Synced: 2025-02-24T15:33:29.733Z (over 1 year ago)
- Topics: cpp
- Language: C++
- Homepage:
- Size: 117 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Slice - URL Parser (C++ Header-Only) Library
Slice is a simple header-only C++ library that allows you to parse URLs and extract their components (scheme, host, path, query, and fragment) using regular expressions.
## Usage
To use the URL Parser in your C++ project, follow these steps:
1. Download the `url_parser.h` header file from this repository.
2. Copy the `url_parser.h` file into your project directory or include it in your project's `include` folder.
## Build
The URL Parser is a header-only library and does not require a separate build process. You can include the `url_parser.h` file directly in your C++ source files, and the parser will be available for use.
## Example
Below is a simple example usage:
```cpp
#include
#include "url_parser.h"
int main() {
std::string url = "https://www.example.com/page?param1=value1¶m2=value2#section";
URLParser::ParsedURL parsedUrl = URLParser::parse(url);
std::cout << "Scheme: " << parsedUrl.scheme << std::endl;
std::cout << "Host: " << parsedUrl.host << std::endl;
std::cout << "Path: " << parsedUrl.path << std::endl;
std::cout << "Fragment: " << parsedUrl.fragment << std::endl;
std::cout << "Query Parameters:" << std::endl;
for (const auto& entry : parsedUrl.query) {
std::cout << entry.first << " = " << entry.second << std::endl;
}
return 0;
}
```
Replace the url variable with any URL you want to parse. The URLParser class will extract its components and provide them in the ParsedURL struct for further use in your application.
## Contributing
Contributions to this project are welcome! If you find any issues or have any improvements, please feel free to open an issue or submit a pull request.