<commit_before>require 'sqrl/base64'
require 'sqrl/key/site'
require 'sqrl/url'
require 'sqrl/tif'

module SQRL
  class ResponseParser
    def initialize(session, params)
      @session = session
      @tif_base = 16

      if (params.respond_to?(:split))
        @params = parse_form(params)
      else
        @params = params
      end

      if @params.any? && !@params.keys.first.kind_of?(String)
        raise ArgumentError, "#{self.class.name} uses string keys for params"
      end

      if @params['server']
        @params = parse_params(decode(@params['server']))<commit_msg>assuming html forms broke top level sqrl response<commit_after>require 'sqrl/base64'
require 'sqrl/key/site'
require 'sqrl/url'
require 'sqrl/tif'

module SQRL
  class ResponseParser
    def initialize(session, params)
      @session = session
      @tif_base = 16

      if (params.respond_to?(:split))
        if params.count("\r") > params.count("&")
          @params = parse_params(params)
        else
          @params = parse_form(params)
        end
      else
        @params = params
      end

      if @params.any? && !@params.keys.first.kind_of?(String)
        raise ArgumentError, "#{self.class.name} uses string keys for params"
      end

      if @params['server']
        @params = parse_params(decode(@params['server']))
{'fraction_non_alphanumeric': 0.12274096385542169, 'fraction_numerical': 0.006024096385542169, 'mean_word_length': 2.7331460674157304, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2983527', 'n_tokens_mistral': 421, 'n_tokens_neox': 405, 'n_words': 99}