Better feedback if no applink schema is provided

This commit is contained in:
Johannes Zellner
2022-10-06 19:49:33 +02:00
parent 6e4e8bf74d
commit cb8d90699b

View File

@@ -38,6 +38,7 @@ function postProcess(result) {
result.ts = new Date(result.ts).getTime();
result.icon = result.icon ? result.icon : null;
}
function validateUpstreamUri(upstreamUri) {
@@ -45,6 +46,8 @@ function validateUpstreamUri(upstreamUri) {
if (!upstreamUri) return new BoxError(BoxError.BAD_FIELD, 'upstreamUri cannot be empty');
if (!upstreamUri.includes('://')) return new BoxError(BoxError.BAD_FIELD, 'upstreamUri has no schema');
const uri = safe(() => new URL(upstreamUri));
if (!uri) return new BoxError(BoxError.BAD_FIELD, `upstreamUri is invalid: ${safe.error.message}`);
if (uri.protocol !== 'http:' && uri.protocol !== 'https:') return new BoxError(BoxError.BAD_FIELD, 'upstreamUri has an unsupported scheme');