Skip to content

cpp-netlib/url

Repository files navigation

Skyr URL

Build Status

License

This library provides:

  • A skyr::url class that implements a generic URI parser, compatible with WhatWG URL specification
  • Percent encoding and decoding functions
  • IDNA and Punycode functions for domain name parsing

Building the project

Building with CMake and Make

mkdir _build
cd _build
cmake ..
make -j4

Running the tests

make test

Examples

Creating a URL without a base URL

auto url = skyr::make_url("http://example.org/\xf0\x9f\x92\xa9");
std::cout << url.value().pathname() << std::endl;

Gives the output: /%F0%9F%92%A9

Creating an non-absolute URL without a base URL

auto url = skyr::make_url(U"/\u1F363\1F37A");
if (!url) {
  std::cerr << "Parsing failed" << std::endl;
}

Gives the output: Parsing failed

Creating a non-absolute URL with a base URL

auto base = skyr::make_url("https://url.spec.whatwg.org/");
auto url = skyr::make_url(U"/\u1F363\1F37A", base.value());
if (url) {
  std::cout << url.value().href() << std::endl;
}

Gives the output: https://url.spec.whatwg.org/%F0%9F%8D%A3%F0%9F%8D%BA

Dependencies

This library uses optional and expected.

The tests are built using Google Test.

Requirements

This library has been tested using the following compilers:

Linux:

  • GCC 6
  • GCC 7
  • GCC 8
  • Clang 5
  • Clang 6

MacOS:

  • Clang 5
  • Clang 6

Windows:

  • Visual Studio 2017

License

This library is released under the Boost Software License (please see http://boost.org/LICENSE_1_0.txt or the accompanying LICENSE_1_0.txt file for the full text.

Contact

Any questions about this library can be addressed to the cpp-netlib developers mailing list. Issues can be filed using Github at http://github.com/cpp-netlib/uri/issues.

About

A C++ library that implements the WhatWG URL specification

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Contributors

Languages

  • C++ 96.0%
  • CMake 3.6%
  • Python 0.4%