summaryrefslogtreecommitdiff
path: root/vendor/gopkg.in/square/go-jose.v2/encoding.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/gopkg.in/square/go-jose.v2/encoding.go')
-rw-r--r--vendor/gopkg.in/square/go-jose.v2/encoding.go14
1 files changed, 10 insertions, 4 deletions
diff --git a/vendor/gopkg.in/square/go-jose.v2/encoding.go b/vendor/gopkg.in/square/go-jose.v2/encoding.go
index b9687c647..70f7385c4 100644
--- a/vendor/gopkg.in/square/go-jose.v2/encoding.go
+++ b/vendor/gopkg.in/square/go-jose.v2/encoding.go
@@ -23,13 +23,12 @@ import (
"encoding/binary"
"io"
"math/big"
- "regexp"
+ "strings"
+ "unicode"
"gopkg.in/square/go-jose.v2/json"
)
-var stripWhitespaceRegex = regexp.MustCompile("\\s")
-
// Helper function to serialize known-good objects.
// Precondition: value is not a nil pointer.
func mustSerializeJSON(value interface{}) []byte {
@@ -56,7 +55,14 @@ func mustSerializeJSON(value interface{}) []byte {
// Strip all newlines and whitespace
func stripWhitespace(data string) string {
- return stripWhitespaceRegex.ReplaceAllString(data, "")
+ buf := strings.Builder{}
+ buf.Grow(len(data))
+ for _, r := range data {
+ if !unicode.IsSpace(r) {
+ buf.WriteRune(r)
+ }
+ }
+ return buf.String()
}
// Perform compression based on algorithm