summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Herold <github@michaeljherold.com>2023-01-21 13:45:17 -0600
committerGitHub <noreply@github.com>2023-01-22 08:45:17 +1300
commit16a7dd62eb597d2ec164d40cb02f9e49c2ac81eb (patch)
tree307f76262ad55b4695f980fe0b51093f297247be
parentd430f52ea54acf9e8aba35123a462996f523057f (diff)
downloadrack-16a7dd62eb597d2ec164d40cb02f9e49c2ac81eb.tar.gz
Remove single-character classes from query parser (#2024)
When studying the code for how Rack handles parsing query strings, I was confused as to why there were character classes of a single character. Looking through the Git history this seemed to be because the original splitter split on both ampersands and semicolons and the style was kept around so they all _looked_ the same even though some of the others were single-character classes. After checking that all of the tests passed, I was curious if there was any performance difference. There isn't, likely because there's no capture involved. This change drops the redundant character classes to make it so no one else is confused by the presence of the character classes.
-rw-r--r--lib/rack/query_parser.rb4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/rack/query_parser.rb b/lib/rack/query_parser.rb
index 7c9621ed..f71bd765 100644
--- a/lib/rack/query_parser.rb
+++ b/lib/rack/query_parser.rb
@@ -4,8 +4,8 @@ require_relative 'bad_request'
module Rack
class QueryParser
- DEFAULT_SEP = /[&] */n
- COMMON_SEP = { ";" => /[;] */n, ";," => /[;,] */n, "&" => /[&] */n }
+ DEFAULT_SEP = /& */n
+ COMMON_SEP = { ";" => /; */n, ";," => /[;,] */n, "&" => /& */n }
# ParameterTypeError is the error that is raised when incoming structural
# parameters (parsed by parse_nested_query) contain conflicting types.