mirror of
https://github.com/clockworklabs/SpacetimeDB.git
synced 2026-05-10 17:49:49 -04:00
9fbb322b0b
## Problem `spacetime generate --out-dir ../frontend-ts-src/module-bindings` was resolving the path incorrectly, stripping the leading `..` component. Reported in #4429 via a [user report on Discord](https://discord.com/channels/1037340874172014652/1475935288919462072/1475935288919462072). ## Root Cause `normalize_path_lexical()` in `spacetime_config.rs` used `PathBuf::pop()` to handle `..` components, but `pop()` is a no-op on an empty `PathBuf`. This silently dropped leading `..` segments: - Input: `../frontend-ts-src/module-bindings` - Output: `frontend-ts-src/module-bindings` (wrong — `..` was eaten) ## Fix Replace the `PathBuf`-based normalization with a `Vec<Component>` stack approach. `..` only cancels a preceding `Normal` component; otherwise it is preserved. This correctly handles: - `../foo` → `../foo` (leading `..` preserved) - `../../a/b` → `../../a/b` (multiple leading `..` preserved) - `a/b/../c` → `a/c` (inner `..` still resolves) - `/home/user/project/../foo` → `/home/user/foo` (absolute paths work) ## Testing Added `test_normalize_path_preserves_leading_dotdot` covering all edge cases. Closes #4429 --------- Co-authored-by: clockwork-labs-bot <bot@clockworklabs.com> Co-authored-by: clockwork-labs-bot <clockwork-labs-bot@users.noreply.github.com>