]> git.openstreetmap.org Git - rails.git/blob - config/initializers/oauth.rb
Add frozen_string_literal comments to ruby files
[rails.git] / config / initializers / oauth.rb
1 # frozen_string_literal: true
2
3 require "oauth/helper"
4
5 module OAuth
6   module Helper
7     def escape(value)
8       value.to_s.gsub(OAuth::RESERVED_CHARACTERS) do |c|
9         c.bytes.map do |b|
10           format("%%%02X", b)
11         end.join
12       end.force_encoding(Encoding::US_ASCII)
13     end
14
15     def unescape(value)
16       value.to_s.gsub(/%\h{2}/) do |c|
17         c[1..].to_i(16).chr
18       end.force_encoding(Encoding::UTF_8)
19     end
20   end
21 end