( url: string, content?: string, options?: HyperlinkOptions, )
| 22 | * @param options - Optional overrides for testing (supportsHyperlinks) |
| 23 | */ |
| 24 | export function createHyperlink( |
| 25 | url: string, |
| 26 | content?: string, |
| 27 | options?: HyperlinkOptions, |
| 28 | ): string { |
| 29 | const hasSupport = options?.supportsHyperlinks ?? supportsHyperlinks() |
| 30 | if (!hasSupport) { |
| 31 | return url |
| 32 | } |
| 33 | |
| 34 | // Apply basic ANSI blue color - wrap-ansi preserves this across line breaks |
| 35 | // RGB colors (like theme colors) are NOT preserved by wrap-ansi with OSC 8 |
| 36 | const displayText = content ?? url |
| 37 | const coloredText = chalk.blue(displayText) |
| 38 | return `${OSC8_START}${url}${OSC8_END}${coloredText}${OSC8_START}${OSC8_END}` |
| 39 | } |
| 40 |
no test coverage detected