Skip to main content

Function: safeGetHostname()

safeGetHostname(urlString: string): string

Defined in: src/utils/monitoring/dataValidation.ts:85

Safely extracts hostname from a URL string.

Parametersโ€‹

urlStringโ€‹

string

The URL string to extract hostname from.

Returnsโ€‹

string

The hostname when the URL is valid; otherwise an empty string.

Remarksโ€‹

Applies shared URL validation before attempting to construct a URL. Any parsing failures return an empty string so consumers can fall back to a neutral display value without crashing.