@@ -10,42 +10,43 @@ const HOSTS_REGEX = new RegExp(
10
10
String . raw `(?<protocol>mongodb(?:\+srv|)):\/\/(?:(?<username>[^:]*)(?::(?<password>[^@]*))?@)?(?<hosts>(?!:)[^\/?@]+)(?<rest>.*)`
11
11
) ;
12
12
13
- class CaseInsenstiveURLSearchParams extends URLSearchParams {
14
- append ( name : any , value : any ) : void {
15
- return super . append ( this . _normalizeKey ( name ) , value ) ;
16
- }
13
+ const caseInsenstiveURLSearchParams = ( Ctor : typeof URLSearchParams ) =>
14
+ class CaseInsenstiveURLSearchParams extends Ctor {
15
+ append ( name : any , value : any ) : void {
16
+ return super . append ( this . _normalizeKey ( name ) , value ) ;
17
+ }
17
18
18
- delete ( name : any ) : void {
19
- return super . delete ( this . _normalizeKey ( name ) ) ;
20
- }
19
+ delete ( name : any ) : void {
20
+ return super . delete ( this . _normalizeKey ( name ) ) ;
21
+ }
21
22
22
- get ( name : any ) : string | null {
23
- return super . get ( this . _normalizeKey ( name ) ) ;
24
- }
23
+ get ( name : any ) : string | null {
24
+ return super . get ( this . _normalizeKey ( name ) ) ;
25
+ }
25
26
26
- getAll ( name : any ) : string [ ] {
27
- return super . getAll ( this . _normalizeKey ( name ) ) ;
28
- }
27
+ getAll ( name : any ) : string [ ] {
28
+ return super . getAll ( this . _normalizeKey ( name ) ) ;
29
+ }
29
30
30
- has ( name : any ) : boolean {
31
- return super . has ( this . _normalizeKey ( name ) ) ;
32
- }
31
+ has ( name : any ) : boolean {
32
+ return super . has ( this . _normalizeKey ( name ) ) ;
33
+ }
33
34
34
- set ( name : any , value : any ) : void {
35
- return super . set ( this . _normalizeKey ( name ) , value ) ;
36
- }
35
+ set ( name : any , value : any ) : void {
36
+ return super . set ( this . _normalizeKey ( name ) , value ) ;
37
+ }
37
38
38
- _normalizeKey ( name : any ) : string {
39
- name = `${ name } ` ;
40
- for ( const key of this . keys ( ) ) {
41
- if ( key . toLowerCase ( ) === name . toLowerCase ( ) ) {
42
- name = key ;
43
- break ;
39
+ _normalizeKey ( name : any ) : string {
40
+ name = `${ name } ` ;
41
+ for ( const key of this . keys ( ) ) {
42
+ if ( key . toLowerCase ( ) === name . toLowerCase ( ) ) {
43
+ name = key ;
44
+ break ;
45
+ }
44
46
}
47
+ return name ;
45
48
}
46
- return name ;
47
- }
48
- }
49
+ } ;
49
50
50
51
// Abstract middle class to appease TypeScript, see https://github.com/microsoft/TypeScript/pull/37894
51
52
abstract class URLWithoutHost extends URL {
@@ -114,7 +115,7 @@ export class ConnectionString extends URLWithoutHost {
114
115
if ( ! this . pathname ) {
115
116
this . pathname = '/' ;
116
117
}
117
- Object . setPrototypeOf ( this . searchParams , CaseInsenstiveURLSearchParams . prototype ) ;
118
+ Object . setPrototypeOf ( this . searchParams , caseInsenstiveURLSearchParams ( this . searchParams . constructor as any ) . prototype ) ;
118
119
}
119
120
120
121
// The getters here should throw, but that would break .toString() because of
0 commit comments