refactor: dedupe channel trimmed readers

This commit is contained in:
Peter Steinberger
2026-04-08 00:03:28 +01:00
parent ee0425a705
commit ef903d881e
15 changed files with 62 additions and 48 deletions

View File

@@ -1,4 +1,5 @@
import { type NodeMatchCandidate, resolveNodeIdFromCandidates } from "./node-match.js";
import { normalizeOptionalString } from "./string-coerce.js";
type ResolveNodeFromListOptions<TNode extends NodeMatchCandidate> = {
allowDefault?: boolean;
@@ -10,7 +11,7 @@ export function resolveNodeIdFromNodeList<TNode extends NodeMatchCandidate>(
query?: string,
options: ResolveNodeFromListOptions<TNode> = {},
): string {
const q = String(query ?? "").trim();
const q = normalizeOptionalString(query) ?? "";
if (!q) {
if (options.allowDefault === true && options.pickDefaultNode) {
const picked = options.pickDefaultNode(nodes);