Skip to main content

resolve_path

Function resolve_path 

Source
pub fn resolve_path(
    path: &str,
    keys: &[String],
    entry: &str,
) -> (String, String)
Expand description

Resolve a requested path against the set of known page keys (each a .lmn filename stem), returning (page_key, segment).

Algorithm - the framework does not pattern-match segments:

  1. Strip a leading /. An empty path resolves to entry (the home page).
  2. Try the full path as a page key; if absent, walk up one segment at a time to the longest existing prefix (/user/7 -> user when only user.lmn exists).
  3. The leftover tail after the matched prefix becomes the segment (/7), for the page’s own code to parse. A whole-path miss falls back to entry with the normalised path as the segment.