Skip to content

std: nav package for route matching and history - #3732

Merged
BaseMax merged 1 commit into
mainfrom
std-nav
Nov 21, 2026
Merged

BaseMax merged 1 commit into
mainfrom
std-nav

Conversation

@BaseMax

@BaseMax BaseMax commented Nov 21, 2026

Copy link
Copy Markdown
Member

Shared logic for page routing on web, native and server: route patterns (:id, :id?, *rest), params, query values, link resolution, specificity ranking and a back/forward history stack. Pure Salam, no state.

  • Tests: tests/{en,fa}/stdlib/nav_routes (68 asserts), also passing when compiled with salam js and run under node, Persian paths included.
  • Docs page 191 en+fa with examples; stdlib index regenerated.

@BaseMax
BaseMax requested a review from a team as a code owner November 21, 2026 04:58
@coderabbitai

coderabbitai Bot commented Nov 21, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 43 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 2 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 89ea2cf1-20f9-40be-9530-382a129532a0
Commits

Reviewing files that changed from the base of the PR and between 0c6ebc8 and 6856c12.

Files ignored due to path filters: 8

  • tests/en/stdlib/nav_routes.out is excluded by !**/*.out
  • tests/fa/stdlib/nav_routes.out is excluded by !**/*.out
  • website/content/en/std-examples/nav/nav-History.out is excluded by !**/*.out
  • website/content/en/std-examples/nav/nav-Match.out is excluded by !**/*.out
  • website/content/en/std-examples/nav/nav-Resolve.out is excluded by !**/*.out
  • website/content/fa/std-examples/nav/nav-History.out is excluded by !**/*.out
  • website/content/fa/std-examples/nav/nav-Match.out is excluded by !**/*.out
  • website/content/fa/std-examples/nav/nav-Resolve.out is excluded by !**/*.out
Files selected for processing: 12

  • docs/ai/stdlib-index.json
  • std/nav/nav.salam
  • tests/en/stdlib/nav_routes.salam
  • tests/fa/stdlib/nav_routes.salam
  • website/content/en/std-examples/nav/nav-History.salam
  • website/content/en/std-examples/nav/nav-Match.salam
  • website/content/en/std-examples/nav/nav-Resolve.salam
  • website/content/en/std/191-nav.txt
  • website/content/fa/std-examples/nav/nav-History.salam
  • website/content/fa/std-examples/nav/nav-Match.salam
  • website/content/fa/std-examples/nav/nav-Resolve.salam
  • website/content/fa/std/191-nav.txt
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@BaseMax
BaseMax merged commit 3d0dd9e into main Nov 21, 2026
15 checks passed
@BaseMax
BaseMax deleted the std-nav branch November 21, 2026 04:59
@github-actions

Copy link
Copy Markdown
Contributor
sha=6856c128e7ae00d9c382bfdb80fa9246b290ad06

🤖 Salam AI review

Verdict: 🛠️ Changes needed before merging

commit 6856c12 · 20 files · +1031 −0 · model salam

Summary

This pull request adds a new pure-Salam nav package implementing route patterns, parameters, query parsing, link resolution, specificity ranking and a back/forward history stack, plus tests and documentation. The implementation is well structured and matches the documented API, but it does not compile as submitted: _param_name references an undefined variable and IsInt is declared with the wrong return type.

What changed

A new std/nav/nav.salam package (with English/Persian names) provides Route/History structs and functions for matching paths against patterns (:id, :id?, *rest), reading params and query values, normalizing/resolving links, ranking routes, and a mutable history stack. Tests in tests/{en,fa}/stdlib/nav_routes and website examples/docs page 191 are added, and docs/ai/stdlib-index.json is regenerated to include nav.

Review

  1. std/nav/nav.salam, _param_name (around line 103): ret str.Substr(s, 1, n) references an undefined identifier s; the parameter is named seg. This is a compile error (E001) and breaks every param lookup. Fix to str.Substr(seg, 1, n).
  2. std/nav/nav.salam, IsInt (around line 330): declared as pub func IsInt(s: str): str: but returns bool (three ret false/ret true sites). This is a compile error (E002) and also contradicts the regenerated index entry pub func IsInt(s: str): bool:. Fix the declared return type to bool.
  3. std/nav/nav.salam, _capture: the optional-segment branch when i >= xs.Len() correctly skips, but please double-check patterns where an optional segment is followed by further literal segments (e.g. /a/:b?/c), the current logic may accept a path that omits the optional segment yet still has a trailing segment. This is a question based on reading the code, since I could not run the suite.
  4. docs/ai/stdlib-index.json: the regenerated diff also adds unrelated packages/entries (gui.tray, net.wifi, HideWindow, OnCloseRequest, etc.). Is that intended for this PR, or was the index regenerated against a newer base? Please confirm to avoid accidental churn.
  5. std/nav/nav.salam, Unescape: the guard i + 2 < n is correct for needing three characters, but note it silently leaves malformed %XX sequences untouched, which matches the documented "only reserved escapes" behaviour, fine, just confirming intent.

Tests

The PR claims 68 asserts pass in both English and Persian, including salam js/node. I could not run them; however, the two compile errors above mean the package cannot type-check as submitted, so the claimed test run must have used a corrected copy. Please fix the two errors and re-run salam check/the test harness before merging.

Risks

Beyond the compile errors, the main risk is subtle matching bugs in _capture for optional and splat combinations; the existing tests cover the common cases but not deeply nested optional/splat mixes. The history implementation relies on Vector.Set/Vector.Clear, which appear available. No platform or state dependencies are introduced, consistent with the "pure Salam" claim.


⚠️ This review was written automatically by an AI and may contain mistakes. It is a helper for maintainers, not a replacement for a human review: check the code yourself before merging.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant