MCPcopy Index your code
hub / github.com/coder/mux / normalizeOptionalModelString

Function normalizeOptionalModelString

src/node/config.ts:355–376  ·  view source on GitHub ↗
(value: unknown)

Source from the content-addressed store, hash-verified

353}
354
355function normalizeOptionalModelString(value: unknown): string | undefined {
356 if (typeof value !== "string") {
357 return undefined;
358 }
359
360 const trimmed = value.trim();
361 if (!trimmed) {
362 return undefined;
363 }
364
365 // Reject malformed mux-gateway strings ("mux-gateway:provider" without "/model").
366 if (trimmed.startsWith("mux-gateway:") && !trimmed.includes("/")) {
367 return undefined;
368 }
369
370 const normalized = normalizeSelectedModel(trimmed);
371 if (!isValidModelFormat(normalized)) {
372 return undefined;
373 }
374
375 return normalized;
376}
377
378function normalizeOptionalModelStringArray(value: unknown): string[] | undefined {
379 if (!Array.isArray(value)) {

Callers 4

loadConfigOrDefaultMethod · 0.85
saveConfigMethod · 0.85

Calls 2

normalizeSelectedModelFunction · 0.90
isValidModelFormatFunction · 0.90

Tested by

no test coverage detected