@@ -71,7 +71,7 @@ function validateConflicts(options: CliOptions, connectionString?: ConnectionStr
71
71
* @param {string } host - The value of the --host option.
72
72
*/
73
73
function validateHost ( host : string ) : void {
74
- const invalidCharacter = host . match ( / [ ^ a - z A - Z 0 - 9 . : \[ \] - ] / ) ;
74
+ const invalidCharacter = host . match ( / [ ^ a - z A - Z 0 - 9 . : \[ \] _ - ] / ) ;
75
75
if ( invalidCharacter ) {
76
76
throw new MongoshInvalidInputError (
77
77
i18n . __ ( INVALID_HOST ) + ': ' + invalidCharacter [ 0 ] ,
@@ -149,7 +149,7 @@ function generateUriNormalized(options: CliOptions): ConnectionString {
149
149
// If the --host argument contains /, it has the format
150
150
// <replSetName>/<hostname1><:port>,<hostname2><:port>,<...>
151
151
const replSetHostMatch = ( options . host ?? '' ) . match (
152
- / ^ (?< replSetName > [ ^ / ] + ) \/ (?< hosts > ( [ A - Z a - z 0 - 9 . - ] + ( : \d + ) ? , ? ) + ) $ /
152
+ / ^ (?< replSetName > [ ^ / ] + ) \/ (?< hosts > ( [ A - Z a - z 0 - 9 . _ - ] + ( : \d + ) ? , ? ) + ) $ /
153
153
) ;
154
154
if ( replSetHostMatch ) {
155
155
const { replSetName, hosts } = replSetHostMatch . groups as { replSetName : string , hosts : string } ;
@@ -162,7 +162,7 @@ function generateUriNormalized(options: CliOptions): ConnectionString {
162
162
// If the --host argument contains multiple hosts as a seed list
163
163
// we directly do not do additional host/port parsing
164
164
const seedList = ( options . host ?? '' ) . match (
165
- / ^ (?< hosts > ( [ A - Z a - z 0 - 9 . - ] + ( : \d + ) ? , ? ) + ) $ /
165
+ / ^ (?< hosts > ( [ A - Z a - z 0 - 9 . _ - ] + ( : \d + ) ? , ? ) + ) $ /
166
166
) ;
167
167
if ( seedList && options . host ?. includes ( ',' ) ) {
168
168
const { hosts } = seedList . groups as { hosts : string } ;
@@ -190,7 +190,7 @@ function generateUriNormalized(options: CliOptions): ConnectionString {
190
190
191
191
// Capture host, port and db from the string and generate a URI from
192
192
// the parts. If there is a db part, it *must* start with /.
193
- const uriMatch = / ^ ( [ A - Z a - z 0 - 9 ] [ A - Z a - z 0 - 9 . - ] + ) : ? ( \d + ) ? (?: \/ ( \S * ) ) ? $ / gi;
193
+ const uriMatch = / ^ ( [ A - Z a - z 0 - 9 ] [ A - Z a - z 0 - 9 . _ - ] + ) : ? ( \d + ) ? (?: \/ ( \S * ) ) ? $ / gi;
194
194
let parts : string [ ] | null = uriMatch . exec ( uri ) ;
195
195
196
196
if ( parts === null ) {
0 commit comments