<commit_before><commit_msg>added URI.decode_www_form<commit_after># frozen_string_literal: true

module URI
	def self.decode_www_form(str, separator: '&', isindex: false)
		%x{
			var str = #{str};
			var ary = [];
			if (str.length == 0) {
				return ary;
			}
			var parts = str.split(#{separator});
			for (var i = 0; i < parts.length; i++) {
				var string = parts[i];
				var comps = string.split('=');
				var key = comps[0];
				var val = comps[1];
				if (#{isindex}) {
					if (comps.length < 2) {
						val = key;
						key = '';
					}
				}

				key = decodeURIComponent(key.replace(/\+/g, ' '));
				if (val) {
					val = decodeURIComponent(val.replace(/\+/g, ' '));
				} else {
					val = '';
				}
				ary.push([key, val]);
			}
			return ary;
		}
	end
end
{'fraction_non_alphanumeric': 0.18523316062176165, 'fraction_numerical': 0.006476683937823834, 'mean_word_length': 2.346320346320346, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '4388586', 'n_tokens_mistral': 380, 'n_tokens_neox': 295, 'n_words': 66}