refactor: remove internal ID for URL sequences (#2416)
This commit is contained in:
1 parent
80d532df52
commit
7829dd0357
2 files changed
+6
-22
No files matched your search
+3
-10
@@ -1,8 +1,6 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"crypto/sha256"
|
||||
"encoding/hex"
|
||||
"log"
|
||||
"strconv"
|
||||
"strings"
|
||||
@@ -236,10 +234,6 @@ loop:
|
||||
// It currently supports OSC 8 hyperlinks only, implemented as specified by
|
||||
// https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda.
|
||||
func applyOSC(body string, st tcell.Style) tcell.Style {
|
||||
genAutoID := func(url string) string {
|
||||
sum := sha256.Sum256([]byte(url))
|
||||
return "lf_hyperlink_" + hex.EncodeToString(sum[:8])
|
||||
}
|
||||
extractID := func(params string) string {
|
||||
for seg := range strings.SplitSeq(params, ":") {
|
||||
if seg == "" {
|
||||
@@ -265,14 +259,13 @@ func applyOSC(body string, st tcell.Style) tcell.Style {
|
||||
if url == "" {
|
||||
return st
|
||||
}
|
||||
|
||||
st = st.Url(url)
|
||||
// Optional property used to identify grouped hyperlinks.
|
||||
// Use hash as a fallback to ensure a "unique" id.
|
||||
if id := extractID(toks[1]); id != "" {
|
||||
st = st.UrlId(id)
|
||||
} else {
|
||||
st = st.UrlId(genAutoID(url))
|
||||
}
|
||||
return st.Url(url)
|
||||
return st
|
||||
default:
|
||||
return st
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user