File tree 2 files changed +15
-16
lines changed
2 files changed +15
-16
lines changed Original file line number Diff line number Diff line change 3
3
## next / unreleased
4
4
5
5
* Quash frozen string warnings in Ruby 3.4. (#661 ) @simpl1g
6
+ * Quash URI::Parser warnings in Ruby 3.4. (#662 ) @flavorjones
6
7
7
8
8
9
## 2.12.2 / 2023-10-02
Original file line number Diff line number Diff line change @@ -134,29 +134,27 @@ def self.detect_charset(src)
134
134
end
135
135
136
136
def self . uri_escape str , unsafe = nil
137
- @parser ||= begin
138
- URI ::Parser . new
139
- rescue NameError
140
- URI
141
- end
142
-
143
- if URI == @parser then
137
+ if URI == parser then
144
138
unsafe ||= URI ::UNSAFE
145
139
else
146
- unsafe ||= @ parser. regexp [ :UNSAFE ]
140
+ unsafe ||= parser . regexp [ :UNSAFE ]
147
141
end
148
142
149
- @ parser. escape str , unsafe
143
+ parser . escape str , unsafe
150
144
end
151
145
152
146
def self . uri_unescape str
153
- @parser ||= begin
154
- URI ::Parser . new
155
- rescue NameError
156
- URI
157
- end
158
-
159
- @parser . unescape str
147
+ parser . unescape str
160
148
end
161
149
150
+ def self . parser
151
+ @parser ||=
152
+ if defined? ( URI ::RFC2396_PARSER )
153
+ URI ::RFC2396_PARSER
154
+ elsif defined? ( URI ::Parser )
155
+ URI ::Parser . new
156
+ else
157
+ URI
158
+ end
159
+ end
162
160
end
You can’t perform that action at this time.
0 commit comments