From 5a5091c967bd434786ef3e9af40990740d15b1d2 Mon Sep 17 00:00:00 2001 From: Stephen von Takach Date: Mon, 30 Aug 2021 10:23:15 +1000 Subject: [PATCH] chore: run crystal tool format and fix ameba issues --- .gitignore | 2 +- spec/jwt_spec.cr | 4 ++-- src/jwt.cr | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index df9315d..70e1427 100644 --- a/.gitignore +++ b/.gitignore @@ -3,7 +3,7 @@ /libs/ /.crystal/ /.shards/ - +/bin/ # Libraries don't need dependency lock # Dependencies will be locked in application that uses them diff --git a/spec/jwt_spec.cr b/spec/jwt_spec.cr index 41499c8..8d88e1d 100644 --- a/spec/jwt_spec.cr +++ b/spec/jwt_spec.cr @@ -20,7 +20,7 @@ describe JWT do it "decodes and verifies JWT with dynamic key" do token = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJrMSI6InYxIiwiazIiOiJ2MiJ9.spzfy63YQSKdoM3av9HHvLtWzFjPd1hbch2g3T1-nu4" - payload, header = JWT.decode(token, algorithm: JWT::Algorithm::HS256) do |header, payload| + payload, header = JWT.decode(token, algorithm: JWT::Algorithm::HS256) do |_header, _payload| "SecretKey" end header.should eq({"typ" => "JWT", "alg" => "HS256"}) @@ -29,7 +29,7 @@ describe JWT do it "decodes and verifies JWT with dynamic key and auto algorithm" do token = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJrMSI6InYxIiwiazIiOiJ2MiJ9.spzfy63YQSKdoM3av9HHvLtWzFjPd1hbch2g3T1-nu4" - payload, header = JWT.decode(token) do |header, payload| + payload, header = JWT.decode(token) do |_header, _payload| "SecretKey" end header.should eq({"typ" => "JWT", "alg" => "HS256"}) diff --git a/src/jwt.cr b/src/jwt.cr index 1f19515..c4630d2 100644 --- a/src/jwt.cr +++ b/src/jwt.cr @@ -84,7 +84,7 @@ module JWT payload_json = Base64.decode_string(encoded_payload) payload = JSON.parse(payload_json) - { header, payload } + {header, payload} rescue error : Base64::Error raise DecodeError.new("Invalid Base64", error) rescue error : JSON::ParseException