MCPcopy Create free account
hub / github.com/pterm/pterm / StripOSC8Hyperlinks

Function StripOSC8Hyperlinks

internal/utils.go:20–23  ·  view source on GitHub ↗

StripOSC8Hyperlinks removes OSC 8 hyperlink sequences and keeps only the visible link text. OSC 8 format: \033]8;;URL\033\\LINK_TEXT\033]8;;\033\\ Only LINK_TEXT is visible in the terminal, so we keep only that part.

(s string)

Source from the content-addressed store, hash-verified

18// OSC 8 format: \033]8;;URL\033\\LINK_TEXT\033]8;;\033\\
19// Only LINK_TEXT is visible in the terminal, so we keep only that part.
20func StripOSC8Hyperlinks(s string) string {
21 // Replace OSC 8 hyperlinks with just the link text (capture group 1)
22 return osc8Regex.ReplaceAllString(s, "$1")
23}
24
25// RemoveEscapeCodes removes both OSC 8 hyperlinks and ANSI color codes from a string.
26// This should be used when calculating the visible width of a string for rendering.

Callers 2

TestStripOSC8HyperlinksFunction · 0.85
RemoveEscapeCodesFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestStripOSC8HyperlinksFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…