From 6af6de525d9cec885513f7a658a6e0aa75f3ef5e Mon Sep 17 00:00:00 2001 From: Julik Tarkhanov Date: Mon, 29 Jan 2024 11:00:25 +0100 Subject: [PATCH] Relocate into constant --- lib/jwt/jwk/ec.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/jwt/jwk/ec.rb b/lib/jwt/jwk/ec.rb index 99f924d4..32dee96f 100644 --- a/lib/jwt/jwk/ec.rb +++ b/lib/jwt/jwk/ec.rb @@ -11,6 +11,7 @@ class EC < KeyBase # rubocop:disable Metrics/ClassLength EC_PUBLIC_KEY_ELEMENTS = %i[kty crv x y].freeze EC_PRIVATE_KEY_ELEMENTS = %i[d].freeze EC_KEY_ELEMENTS = (EC_PRIVATE_KEY_ELEMENTS + EC_PUBLIC_KEY_ELEMENTS).freeze + ZERO_BYTE = "\0".b.freeze def initialize(key, params = nil, options = {}) params ||= {} @@ -221,7 +222,7 @@ def decode_octets(base64_encoded_coordinate) # to check for this truncation is thus to check whether the number of bytes # is odd, and restore the leading 0-byte if it is. if bytes.bytesize.odd? - "\0".b + bytes + ZERO_BYTE + bytes else bytes end