Skip to content

Commit

Permalink
remove unneeded complexity
Browse files Browse the repository at this point in the history
  • Loading branch information
ainghazal committed Jun 27, 2024
1 parent da1e5b4 commit 274961f
Showing 1 changed file with 1 addition and 16 deletions.
17 changes: 1 addition & 16 deletions internal/oonirun/v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"fmt"
"strings"
"sync/atomic"
"unicode"

"github.com/hexops/gotextdiff"
"github.com/hexops/gotextdiff/myers"
Expand Down Expand Up @@ -328,21 +327,7 @@ func v2ReadBearerTokenFromFile(fileName string) (string, error) {
if scanner.Scan() {
line := scanner.Text()

// trim any non printable characters (like control chars)
trimmed := strings.TrimFunc(line, func(r rune) bool {
return !unicode.IsPrint(r)
})

// tokenize by whitespace
tokens := strings.Fields(trimmed)

// return empty string if tokens is empty
if len(tokens) <= 0 {
return "", nil
}

// ignore all tokens after the first
token := tokens[0]
token := strings.TrimSpace(line)

// if this is not a valid base64 token, return empty string
if _, err := base64.StdEncoding.DecodeString(token); err != nil {
Expand Down

0 comments on commit 274961f

Please sign in to comment.