Skip to content
Source
Sign inSign up
Open History to see the last commit

pullRequestUtils.ts

24 lines792 Bytes

1import * as DateTime from "effect/DateTime";
2import * as Option from "effect/Option";
3​
4export function trimOptionalString(value: string | null | undefined): string | null {
5 const trimmed = value?.trim() ?? "";
6 return trimmed.length > 0 ? trimmed : null;
7}
8​
9export function isCommitSha(value: string): boolean {
10 return /^[0-9a-f]{7,64}$/i.test(value);
12​
13/** Normalize host timestamps to UTC for cross-host string sorting. */
14export function toIsoUtc(value: string): string {
15 return Option.match(DateTime.make(value), { onNone: () => value, onSome: DateTime.formatIso });
17​
18export function normalizeRefName(refName: string): string {
19 return refName.trim().replace(/^refs\/heads\//, "");
21​
22export function normalizeHost(host: string): string {
23 return host.trim().toLowerCase();