Skip to main content

Module path

Module path 

Source
Expand description

URL path utilities for dev servers.

These helpers handle two concerns that every dev server needs:

  1. Strip an application basePath (e.g. /webui/) from incoming URLs on a segment boundary, so /webui-evil/x does NOT match /webui/.
  2. Resolve the remaining path to a file inside an output directory while rejecting traversal, percent-encoded .., backslashes, NUL, and absolute markers in any segment.

Functions§

normalize_base_path
Normalize a basePath to either / or /<segments>/ — exactly one leading and one trailing slash. Used to make matching deterministic.
resolve_safe_path
Resolve a URL path remainder (already base-stripped) to a filesystem path inside out_dir. Returns None for any input that would escape out_dir or that contains components forbidden for security reasons.
strip_base_path
Try to strip base_path from a URL path on a segment boundary.