Step 16: Fix client routing — prefix-agnostic SX URL matching
The /sx/ prefix mismatch: defpage declares paths like /language/docs/<slug>
but browser URLs are /sx/(language.(doc.slug)). find-matching-route used
starts-with? "/(", missing the /sx/ prefix entirely.
Fix: find-matching-route now uses (index-of path "/(") to detect the SX
URL portion regardless of prefix. Works for /sx/, /myapp/, any prefix.
No hardcoded paths.
Also fixed deps-satisfied?: nil deps (unknown) now returns false instead
of true, preventing client-side eval of pages with unresolved components.
Correctly falls back to server fetch.
Verified with Playwright: clicking "Getting Started" on the docs page now
shows "sx:route deps miss for docs-page" → "sx:route server fetch" instead
of the old "sx:route no match (51 routes)".
2 new router tests for prefix stripping. 2914/2914 total, zero failures.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -208,16 +208,34 @@
|
||||
;; find-matching-route with SX URLs
|
||||
;; --------------------------------------------------------------------------
|
||||
|
||||
(defsuite "find-matching-route-sx-urls"
|
||||
(deftest "SX URL auto-converts for matching"
|
||||
(let ((routes (list
|
||||
{:pattern "/language/docs/<slug>"
|
||||
:parsed (parse-route-pattern "/language/docs/<slug>")
|
||||
:name "docs-page"})))
|
||||
(let ((result (find-matching-route "/(language.(doc.introduction))" routes)))
|
||||
(defsuite
|
||||
"find-matching-route-sx-urls"
|
||||
(deftest
|
||||
"SX URL auto-converts for matching"
|
||||
(let
|
||||
((routes (list {:parsed (parse-route-pattern "/language/docs/<slug>") :pattern "/language/docs/<slug>" :name "docs-page"})))
|
||||
(let
|
||||
((result (find-matching-route "/(language.(doc.introduction))" routes)))
|
||||
(assert-true (not (nil? result)))
|
||||
(assert-equal "docs-page" (get result "name"))
|
||||
(assert-equal "introduction" (get (get result "params") "slug"))))))
|
||||
(assert-equal "introduction" (get (get result "params") "slug")))))
|
||||
(deftest
|
||||
"SX URL with /sx/ prefix auto-converts"
|
||||
(let
|
||||
((routes (list {:parsed (parse-route-pattern "/language/docs/<slug>") :pattern "/language/docs/<slug>" :name "docs-page"})))
|
||||
(let
|
||||
((result (find-matching-route "/sx/(language.(doc.introduction))" routes)))
|
||||
(assert-true (not (nil? result)))
|
||||
(assert-equal "docs-page" (get result "name"))
|
||||
(assert-equal "introduction" (get (get result "params") "slug")))))
|
||||
(deftest
|
||||
"SX URL with custom prefix auto-converts"
|
||||
(let
|
||||
((routes (list {:parsed (parse-route-pattern "/geography/") :pattern "/geography/" :name "geo-index"})))
|
||||
(let
|
||||
((result (find-matching-route "/myapp/(geography)" routes)))
|
||||
(assert-true (not (nil? result)))
|
||||
(assert-equal "geo-index" (get result "name"))))))
|
||||
|
||||
|
||||
;; ==========================================================================
|
||||
|
||||
Reference in New Issue
Block a user