← 全部工具

ada-url

热度 85 更新于 开发与构建

WHATWG-compliant and fast URL parser written in modern C++

homebrewauto-collected

安装

Homebrew
brew install ada-url

通过 Homebrew 安装。

Ada

Ada is a fast and spec-compliant URL parser written in C++. Specification for URL parser can be found from the WHATWG website.

Ada library also includes a URLPattern implementation that is compatible with the web-platform tests.

The Ada library passes the full range of tests from the specification, across a wide range of platforms (e.g., Windows, Linux, macOS). It fully supports the relevant Unicode Technical Standard.

A common use of a URL parser is to take a URL string and normalize it. The WHATWG URL specification has been adopted by most browsers. Other tools, such as curl and many standard libraries, follow the RFC 3986. The following table illustrates possible differences in practice (encoding of the host, encoding of the path):

| string source | string value | |:------------------------|:------------------------------------------------------------| | input string | https://www.7‑Eleven.com/Home/Privacy/Montréal | | ada's normalized string | https://www.xn--7eleven-506c.com/Home/Privacy/Montr%C3%A9al | | curl 7.87 | (returns the original unchanged) |

Ada is fast.

On a benchmark where we need to validate and normalize thousands URLs found on popular websites, we find that ada can be several times faster than popular competitors (system: Apple MacBook 2022 with LLVM 14).

      ada ▏  188 ns/URL ███▏
servo url ▏  664 ns/URL ███████████▎
     CURL ▏ 1471 ns/URL █████████████████████████

Ada has improved the performance of the popular JavaScript environment Node.js:

Since Node.js 18, a new URL parser dependency was added to Node.js — Ada. This addition bumped the Node.js performance when parsing URLs to a new level. Some results could reach up to an improvement of 400%. (State of Node.js Performance 2023)

The Ada library is used by important systems besides Node.js such as Redpanda, Kong, Telegram, DataDog, and Cloudflare Workers.

Requirements

The project is otherwise self-contained and it has no dependency. A recent C++ compiler supporting C++20. We test GCC 12 or better, LLVM 14 or better and Microsoft Visual Studio 2022.

Installation

Binary packages for the following systems are currently available:

Quick Start

Linux or macOS users might follow the following instructions if they have a recent C++ compiler installed and a standard utility (wget)