From 3a8ee0dbd6cd1732a8bae5f7d235bcc5ab98d049 Mon Sep 17 00:00:00 2001 From: giles Date: Fri, 6 Mar 2026 21:38:23 +0000 Subject: [PATCH] Fix router.sx: use len not length (correct SX primitive name) Co-Authored-By: Claude Opus 4.6 --- shared/static/scripts/sx-browser.js | 8 ++++---- shared/sx/ref/router.sx | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/shared/static/scripts/sx-browser.js b/shared/static/scripts/sx-browser.js index 5990986..d47e629 100644 --- a/shared/static/scripts/sx-browser.js +++ b/shared/static/scripts/sx-browser.js @@ -14,7 +14,7 @@ // ========================================================================= var NIL = Object.freeze({ _nil: true, toString: function() { return "nil"; } }); - var SX_VERSION = "2026-03-06T21:37:32Z"; + var SX_VERSION = "2026-03-06T21:38:19Z"; function isNil(x) { return x === NIL || x === null || x === undefined; } function isSxTruthy(x) { return x !== false && !isNil(x); } @@ -2366,14 +2366,14 @@ callExpr.push(dictGet(kwargs, k)); } } var splitPathSegments = function(path) { return (function() { var trimmed = (isSxTruthy(startsWith(path, "/")) ? slice(path, 1) : path); return (function() { - var trimmed2 = (isSxTruthy((isSxTruthy(!isEmpty(trimmed)) && endsWith(trimmed, "/"))) ? slice(trimmed, 0, (length(trimmed) - 1)) : trimmed); + var trimmed2 = (isSxTruthy((isSxTruthy(!isEmpty(trimmed)) && endsWith(trimmed, "/"))) ? slice(trimmed, 0, (len(trimmed) - 1)) : trimmed); return (isSxTruthy(isEmpty(trimmed2)) ? [] : split(trimmed2, "/")); })(); })(); }; // make-route-segment var makeRouteSegment = function(seg) { return (isSxTruthy((isSxTruthy(startsWith(seg, "<")) && endsWith(seg, ">"))) ? (function() { - var paramName = slice(seg, 1, (length(seg) - 1)); + var paramName = slice(seg, 1, (len(seg) - 1)); return (function() { var d = {}; d["type"] = "param"; @@ -2394,7 +2394,7 @@ callExpr.push(dictGet(kwargs, k)); } } })(); }; // match-route-segments - var matchRouteSegments = function(pathSegs, parsedSegs) { return (isSxTruthy(!(length(pathSegs) == length(parsedSegs))) ? NIL : (function() { + var matchRouteSegments = function(pathSegs, parsedSegs) { return (isSxTruthy(!(len(pathSegs) == len(parsedSegs))) ? NIL : (function() { var params = {}; var matched = true; forEachIndexed(function(i, parsedSeg) { return (isSxTruthy(matched) ? (function() { diff --git a/shared/sx/ref/router.sx b/shared/sx/ref/router.sx index 621bbe6..8c10635 100644 --- a/shared/sx/ref/router.sx +++ b/shared/sx/ref/router.sx @@ -22,7 +22,7 @@ (let ((trimmed (if (starts-with? path "/") (slice path 1) path))) (let ((trimmed2 (if (and (not (empty? trimmed)) (ends-with? trimmed "/")) - (slice trimmed 0 (- (length trimmed) 1)) + (slice trimmed 0 (- (len trimmed) 1)) trimmed))) (if (empty? trimmed2) (list) @@ -38,7 +38,7 @@ (define make-route-segment (fn (seg) (if (and (starts-with? seg "<") (ends-with? seg ">")) - (let ((param-name (slice seg 1 (- (length seg) 1)))) + (let ((param-name (slice seg 1 (- (len seg) 1)))) (let ((d {})) (dict-set! d "type" "param") (dict-set! d "value" param-name) @@ -61,7 +61,7 @@ (define match-route-segments (fn (path-segs parsed-segs) - (if (not (= (length path-segs) (length parsed-segs))) + (if (not (= (len path-segs) (len parsed-segs))) nil (let ((params {}) (matched true)) @@ -120,7 +120,7 @@ ;; Platform interface — none required ;; -------------------------------------------------------------------------- ;; All functions use only pure primitives: -;; split, slice, starts-with?, ends-with?, length, empty?, +;; split, slice, starts-with?, ends-with?, len, empty?, ;; map, for-each, for-each-indexed, nth, get, dict-set!, merge, ;; list, nil?, not, = ;; --------------------------------------------------------------------------