Giter VIP home page Giter VIP logo

url's Introduction

Skyr URL

Status

License Travis Build Status AppVeyor CircleCI

Introduction

This library provides:

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

Building the project

This project requires the availability of a C++17 compliant compiler and standard library.

Building with CMake and Ninja

From a terminal, execute the following sequence of commands:

> mkdir _build
> cd _build
> cmake .. -G "Ninja"
> ninja

To run the tests, run ninja test from the terminal while in the _build directory:

> ninja test

Building with CMake and Visual Studio 2017

Open Visual Studio 2017, and click on File->Open->Folder, or use the shortcut Ctrl+Shift+Alt+O. Open the root folder of this project. This will load the project in the explorer. To build, simply open the CMake menu and click Build All.

To run the tests, open the CMake menu, click Tests and then run Run Skyr CTests.

Examples

These examples are based on the WhatWG API specification

To build the examples, run cmake as follows:

> cmake .. -G "Ninja" -DSkyr_BUILD_EXAMPLES=ON

Creating a URL without a base URL

This example parses a string, "https://example.org/๐Ÿ’ฉ", without using a base URL:

#include <skyr/url.hpp>
#include <iostream>

int main(int argc, char *argv[]) {
  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 a non-absolute URL without a base URL

This gives an error if the input, "/๐Ÿฃ๐Ÿบ", is not an absolute-URL-with-fragment-string:

#include <skyr/url.hpp>
#include <iostream>

int main(int argc, char *argv[]) {
  auto url = skyr::make_url("\xf0\x9f\x8d\xa3\xf0\x9f\x8d\xba");
  if (!url) {
    std::cerr << "Parsing failed: " << url.error().message() << std::endl;
  }
}

This gives the output: Parsing failed: Not an absolute URL with fragment

Creating a non-absolute URL with a base URL

This example parses a string, "๐Ÿณ๏ธโ€๐ŸŒˆ", using a base URL, "https://example.org/":

#include <skyr/url.hpp>
#include <iostream>

int main(int argc, char *argv[]) {
  auto base = skyr::make_url("https://example.org/");
  auto url = skyr::make_url(
    "\xf0\x9f\x8f\xb3\xef\xb8\x8f\xe2\x80\x8d\xf0\x9f\x8c\x88", base.value());
  if (url) {
    std::cout << url.value().href() << std::endl;
  }
}

This gives the output: https://example.org/%F0%9F%8F%B3%EF%B8%8F%E2%80%8D%F0%9F%8C%88

Installation

Installing with CMake and Ninja

> cmake .. -G "Ninja" -DCMAKE_INSTALL_PREFIX=$PREFIX
> ninja
> ninja test      # optional
> ninja install

Where $PREFIX is the location where you want to install the library. Depending on the location of $PREFIX, you may need to run the install command as an administrator (e.g. on Linux as sudo).

Installing with CMake and Visual Studio 2017

Open the CMake menu, click Install, then Skyr.

Dependencies

This library uses optional, expected and utfcpp.

The tests are built using Google Test.

Requirements

This library has been tested using the following platforms and compilers:

Linux:

  • GCC 7
  • GCC 8
  • Clang 6

MacOS:

  • Clang 6

Windows:

  • Microsoft Visual C++ 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).

optional and expected are each released under the CCO 1.0 License.

Why skyr?

This name was chosen by a random project name generator, which itself was randomly chosen.

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/url/issues.

url's People

Contributors

glynos avatar deanberris avatar ruslo avatar cmbrandenburg avatar ingomueller-net avatar theaquaman avatar zaufi avatar jdemilledt avatar torbjoernk avatar caitp avatar mefyl avatar georgi-d avatar rogiel avatar toonetown avatar plaristote avatar lacop avatar diamond-msc avatar chrismanning avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.