|
Ada 4.1.1
Fast spec-compliant URL parser
|
Compiled set-level matching over URLPattern pathname patterns. More...
#include "ada/common_defs.h"#include "ada/errors.h"#include "ada/expected.h"#include "ada/url_pattern.h"#include <array>#include <cstddef>#include <cstdint>#include <optional>#include <span>#include <string>#include <string_view>#include <vector>Go to the source code of this file.
Compiled set-level matching over URLPattern pathname patterns.
ada::url_pattern_list answers the question "which of my N routes matches this pathname, and what are the parameter values?" in a single walk instead of a loop of N url_pattern::exec calls. The whole route set is compiled once, by ada::parse_url_pattern_list, into a segment trie with per-node dispatch (direct compares for small fanouts, a first-byte index at the root, perfect-hash projection for wide nodes). Matching a pathname against the compiled set is allocation-free and does not execute any regular expression for routes written in the common static / ":param" / "*" subset; other routes are matched through the regex provider, exactly as ada::url_pattern does.
This implements the route-set ("URLPatternList") use case discussed in https://github.com/whatwg/urlpattern/issues/166 for the pathname component.
Correctness does not depend on the fast path: inputs or routes that exceed the fast-path limits (documented on the constants in ada::url_pattern_list_limits) are matched by a sequential fallback with identical priority semantics, never rejected and never answered wrongly.
Definition in file url_pattern_list.h.