LVRS Document Viewer
backend/RouteMatcher.svx
Path: backend/RouteMatcher.svx
RouteMatcher
Location: backend/navigation/routematcher.h / backend/navigation/routematcher.cpp
RouteMatcher is a QML singleton that moves PageRouter path normalization/matching hot paths into C++.
Purpose
- Apply consistent rules for path normalization (
normalizePath). - Perform dynamic segment (
[id]) and rest segment ([...path]) matching in C++. - Reduce repeated string split/join overhead in QML JS loops.
API
normalizePath(path): string- Normalize empty input to
/. - Ensure a leading
/. - Remove trailing
/except for root (/).
- Normalize empty input to
match(path, routePath): map- Returns:
matched: boolparams: map
- Examples:
("/runs/42", "/runs/[id]") -> matched=true, params.id="42"("/logs/a/b", "/logs/[...path]") -> matched=true, params.path="a/b"
- Returns:
Notes
PageRouter.qmlprefersRouteMatcher, and keeps a JS fallback path when unavailable.- Match results are stored in the
PageRouterroute-resolve cache to further reduce repeated lookup cost.