File tree Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -26,15 +26,16 @@ def self.parser=(parser = RFC3986_PARSER)
26
26
remove_const ( :Parser ) if defined? ( Parser )
27
27
const_set ( "Parser" , parser . class )
28
28
29
+ remove_const ( :REGEXP ) if defined? ( REGEXP )
29
30
if Parser == RFC2396_Parser
30
- remove_const ( :REGEXP ) if defined? ( REGEXP )
31
31
const_set ( "REGEXP" , URI ::RFC2396_REGEXP )
32
32
Parser . new . pattern . each_pair do |sym , str |
33
33
unless REGEXP ::PATTERN . const_defined? ( sym )
34
34
REGEXP ::PATTERN . const_set ( sym , str )
35
35
end
36
36
end
37
37
end
38
+
38
39
Parser . new . regexp . each_pair do |sym , str |
39
40
remove_const ( sym ) if const_defined? ( sym )
40
41
const_set ( sym , str )
Original file line number Diff line number Diff line change @@ -10,6 +10,23 @@ def setup
10
10
def teardown
11
11
end
12
12
13
+ def test_parser_switch
14
+ assert_equal ( URI ::Parser , URI ::RFC3986_Parser )
15
+ refute defined? ( ::URI ::REGEXP )
16
+
17
+ URI . parser = URI ::RFC2396_PARSER
18
+
19
+ assert_equal ( URI ::Parser , URI ::RFC2396_Parser )
20
+ assert defined? ( URI ::REGEXP )
21
+
22
+ URI . parser = URI ::RFC3986_PARSER
23
+
24
+ assert_equal ( URI ::Parser , URI ::RFC3986_Parser )
25
+ refute defined? ( URI ::REGEXP )
26
+ ensure
27
+ URI . parser = URI ::RFC3986_PARSER
28
+ end
29
+
13
30
def test_extract
14
31
EnvUtil . suppress_warning do
15
32
assert_equal ( [ 'http://example.com' ] ,
You can’t perform that action at this time.
0 commit comments