Skip to content

Commit 25c865c

Browse files
committed
fix(MongoBinaryUrl): getDownloadUrl: try to create an "URL" to check if the url is valid
1 parent 3ae6a45 commit 25c865c

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

docs/api/config-options.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ Option `DEBUG` is used to enable Debug Output
4949

5050
Option `DOWNLOAD_MIRROR` is used to set which mirror to use
5151

52-
Default / Format: `https://fastdl.mongodb.org`
52+
Default / Format: `https://fastdl.mongodb.org` (protocol needs to be included)
5353

5454
### DOWNLOAD_URL
5555

packages/mongodb-memory-server-core/src/util/MongoBinaryDownloadUrl.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import debug from 'debug';
44
import * as semver from 'semver';
55
import { isNullOrUndefined } from './utils';
66
import { BaseDryMongoBinaryOptions, DryMongoBinary } from './DryMongoBinary';
7+
import { URL } from 'url';
78

89
const log = debug('MongoMS:MongoBinaryDownloadUrl');
910

@@ -39,7 +40,9 @@ export class MongoBinaryDownloadUrl {
3940
if (downloadUrl) {
4041
log(`Using "${downloadUrl}" as the Download-URL`);
4142

42-
return downloadUrl;
43+
const url = new URL(downloadUrl); // check if this is an valid url
44+
45+
return url.toString();
4346
}
4447

4548
const archive = await this.getArchiveName();
@@ -49,7 +52,10 @@ export class MongoBinaryDownloadUrl {
4952
resolveConfig(ResolveConfigVariables.DOWNLOAD_MIRROR) ?? 'https://fastdl.mongodb.org';
5053
log(`Using "${mirror}" as the mirror`);
5154

52-
return `${mirror}/${this.platform}/${archive}`;
55+
const url = new URL(mirror);
56+
url.pathname = `/${this.platform}/${archive}`;
57+
58+
return url.toString();
5359
}
5460

5561
/**

0 commit comments

Comments
 (0)