diff --git a/.gitignore b/.gitignore index 9106b2a..4ea5798 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ /pkg/ /spec/reports/ /tmp/ +Gemfile.lock diff --git a/Gemfile b/Gemfile index 8ba2339..eb86192 100644 --- a/Gemfile +++ b/Gemfile @@ -1,4 +1,4 @@ source "https://rubygems.org" gem "rake" -gem "minitest" +gem "test-unit" diff --git a/lib/base64.rb b/lib/base64.rb index de1e8c0..693aa1f 100644 --- a/lib/base64.rb +++ b/lib/base64.rb @@ -99,9 +99,11 @@ def urlsafe_decode64(str) # NOTE: RFC 4648 does say nothing about unpadded input, but says that # "the excess pad characters MAY also be ignored", so it is inferred that # unpadded input is also acceptable. - str = str.tr("-_", "+/") if !str.end_with?("=") && str.length % 4 != 0 str = str.ljust((str.length + 3) & ~3, "=") + str.tr!("-_", "+/") + else + str = str.tr("-_", "+/") end strict_decode64(str) end