Dropped custom GUID validation function in favour of standard uuid library.
All checks were successful
build / build (push) Successful in 10s

This commit is contained in:
2026-03-07 14:40:55 +01:00
parent fe1b8f0e1f
commit 4dac95e081
4 changed files with 42 additions and 13 deletions

View File

@@ -9,3 +9,4 @@ export {
readCsvFromStdin,
renderOutput,
} from "./cli/utils.ts";
export { getConfig } from "./config/index.ts";

View File

@@ -1,5 +1,7 @@
// SPDX-License-Identifier: MIT
import { validate as validateUuid } from "uuid";
type Scalar = string | number | boolean | null | undefined;
type ScalarRow = Record<string, Scalar>;
@@ -20,7 +22,7 @@ function formatCell(value: unknown): string {
}
const inlineCodePredicates = [
(value: Scalar): boolean => isGuid(value),
(value: Scalar): boolean => typeof value === "string" && validateUuid(value),
(value: Scalar): boolean =>
typeof value === "string"
&& /^(?:\d{1,3}\.){3}\d{1,3}(?:\/(?:\d{1,2}|(?:\d{1,3}\.){3}\d{1,3}))?$/.test(value),
@@ -38,11 +40,6 @@ function renderCell(raw: Scalar, shouldQuote: boolean): string {
return text;
}
function isGuid(value: unknown): value is string {
return typeof value === "string"
&& /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(value);
}
function toAutoHeaderLabel(key: string): string {
const withSpaces = String(key)
.replace(/[_-]+/g, " ")