fix: accept JSON arrays as lists in config loader
ober
ae4c36c618d24f6fa20e60638110ae6479405a99
--- a/gitsafe/config.ss +++ b/gitsafe/config.ss @@ -114,10 +114,14 @@ [_ 'medium])) ;; --- Parse a JSON value as a list of strings --- + ;; Accepts either a vector or a list — `(std text json)` historically + ;; returned vectors for JSON arrays but now returns lists; handle both + ;; so old and new config files behave the same. (def (json->string-list v) - (if (vector? v) - (filter string? (vector->list v)) - '())) + (cond + [(vector? v) (filter string? (vector->list v))] + [(list? v) (filter string? v)] + [else '()])) ;; --- Load config from file --- (def (load-config (path ".gitsafe.json")) @@ -140,9 +144,10 @@ [custom (if (and patterns-obj (hash-key? patterns-obj "custom")) (let ([cv (hash-ref patterns-obj "custom" (vector))]) - (if (vector? cv) - (vector->list cv) - '())) + (cond + [(vector? cv) (vector->list cv)] + [(list? cv) cv] + [else '()])) '())] [excludes (json->string-list (hash-ref obj "exclude" (vector)))] [allowlist-obj (hash-ref obj "allowlist" #f)]