Fix upstreamUri verification

This commit is contained in:
Girish Ramakrishnan
2022-11-23 12:53:21 +01:00
parent 258eea4318
commit 817e950d47
4 changed files with 5 additions and 10 deletions

View File

@@ -467,7 +467,7 @@ function validateBackupFormat(format) {
function validateUpstreamUri(upstreamUri) {
assert.strictEqual(typeof upstreamUri, 'string');
if (!upstreamUri) return null;
if (!upstreamUri) return new BoxError(BoxError.BAD_FIELD, 'upstreamUri cannot be empty');
const uri = safe(() => new URL(upstreamUri));
if (!uri) return new BoxError(BoxError.BAD_FIELD, `upstreamUri is invalid: ${safe.error.message}`);
@@ -1350,7 +1350,7 @@ async function install(data, auditSource) {
error = validateLabel(label);
if (error) throw error;
error = validateUpstreamUri(upstreamUri);
if ('upstreamUri' in data) error = validateUpstreamUri(upstreamUri);
if (error) throw error;
error = validateTags(tags);