Fix router.sx: use len not length (correct SX primitive name)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-06 21:38:23 +00:00
parent c346f525d2
commit 3a8ee0dbd6
2 changed files with 8 additions and 8 deletions

View File

@@ -14,7 +14,7 @@
// ========================================================================= // =========================================================================
var NIL = Object.freeze({ _nil: true, toString: function() { return "nil"; } }); 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 isNil(x) { return x === NIL || x === null || x === undefined; }
function isSxTruthy(x) { return x !== false && !isNil(x); } function isSxTruthy(x) { return x !== false && !isNil(x); }
@@ -2366,14 +2366,14 @@ callExpr.push(dictGet(kwargs, k)); } }
var splitPathSegments = function(path) { return (function() { var splitPathSegments = function(path) { return (function() {
var trimmed = (isSxTruthy(startsWith(path, "/")) ? slice(path, 1) : path); var trimmed = (isSxTruthy(startsWith(path, "/")) ? slice(path, 1) : path);
return (function() { 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, "/")); return (isSxTruthy(isEmpty(trimmed2)) ? [] : split(trimmed2, "/"));
})(); })();
})(); }; })(); };
// make-route-segment // make-route-segment
var makeRouteSegment = function(seg) { return (isSxTruthy((isSxTruthy(startsWith(seg, "<")) && endsWith(seg, ">"))) ? (function() { 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() { return (function() {
var d = {}; var d = {};
d["type"] = "param"; d["type"] = "param";
@@ -2394,7 +2394,7 @@ callExpr.push(dictGet(kwargs, k)); } }
})(); }; })(); };
// match-route-segments // 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 params = {};
var matched = true; var matched = true;
forEachIndexed(function(i, parsedSeg) { return (isSxTruthy(matched) ? (function() { forEachIndexed(function(i, parsedSeg) { return (isSxTruthy(matched) ? (function() {

View File

@@ -22,7 +22,7 @@
(let ((trimmed (if (starts-with? path "/") (slice path 1) path))) (let ((trimmed (if (starts-with? path "/") (slice path 1) path)))
(let ((trimmed2 (if (and (not (empty? trimmed)) (let ((trimmed2 (if (and (not (empty? trimmed))
(ends-with? trimmed "/")) (ends-with? trimmed "/"))
(slice trimmed 0 (- (length trimmed) 1)) (slice trimmed 0 (- (len trimmed) 1))
trimmed))) trimmed)))
(if (empty? trimmed2) (if (empty? trimmed2)
(list) (list)
@@ -38,7 +38,7 @@
(define make-route-segment (define make-route-segment
(fn (seg) (fn (seg)
(if (and (starts-with? seg "<") (ends-with? 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 {})) (let ((d {}))
(dict-set! d "type" "param") (dict-set! d "type" "param")
(dict-set! d "value" param-name) (dict-set! d "value" param-name)
@@ -61,7 +61,7 @@
(define match-route-segments (define match-route-segments
(fn (path-segs parsed-segs) (fn (path-segs parsed-segs)
(if (not (= (length path-segs) (length parsed-segs))) (if (not (= (len path-segs) (len parsed-segs)))
nil nil
(let ((params {}) (let ((params {})
(matched true)) (matched true))
@@ -120,7 +120,7 @@
;; Platform interface — none required ;; Platform interface — none required
;; -------------------------------------------------------------------------- ;; --------------------------------------------------------------------------
;; All functions use only pure primitives: ;; 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, ;; map, for-each, for-each-indexed, nth, get, dict-set!, merge,
;; list, nil?, not, = ;; list, nil?, not, =
;; -------------------------------------------------------------------------- ;; --------------------------------------------------------------------------