From cb8d90699bfeee5323955ac13d8a3a3a26fb6824 Mon Sep 17 00:00:00 2001 From: Johannes Zellner Date: Thu, 6 Oct 2022 19:49:33 +0200 Subject: [PATCH] Better feedback if no applink schema is provided --- src/applinks.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/applinks.js b/src/applinks.js index 5de73ff0e..2ac9ca043 100644 --- a/src/applinks.js +++ b/src/applinks.js @@ -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');