/**
 * `new URL()` that returns null instead of throwing, for addresses from
 * settings that may be empty or mistyped.
 */
export function safeUrl( raw: string | null | undefined, base?: string ): URL | null {
	if ( ! raw ) return null;

	try {
		return new URL( raw, base );
	} catch {
		return null;
	}
}
