diff options
author | Florian Dold <florian.dold@gmail.com> | 2020-01-18 23:32:03 +0100 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2020-01-18 23:32:14 +0100 |
commit | af57a404d070500ce63ed9ed0dfce721e82e4801 (patch) | |
tree | 39e97aefffe61c568b64c1d71d66b48e26c905ce /src/util/taleruri.ts | |
parent | fcb0565323d3134ec2dc376700ef85a2c7b7becd (diff) | |
download | wallet-core-af57a404d070500ce63ed9ed0dfce721e82e4801.tar.xz |
fix and test case for "insecure" taler://refund URIs
Diffstat (limited to 'src/util/taleruri.ts')
-rw-r--r-- | src/util/taleruri.ts | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/src/util/taleruri.ts b/src/util/taleruri.ts index 1b4e4352b..8ad79669f 100644 --- a/src/util/taleruri.ts +++ b/src/util/taleruri.ts @@ -95,13 +95,12 @@ export function classifyTalerUri(s: string): TalerUriType { return TalerUriType.TalerNotifyReserve; } return TalerUriType.Unknown; - } export function getOrderDownloadUrl(merchantBaseUrl: string, orderId: string) { const u = new URL("proposal", merchantBaseUrl); u.searchParams.set("order_id", orderId); - return u.href + return u.href; } export function parsePayUri(s: string): PayUriResult | undefined { @@ -208,7 +207,7 @@ export function parseRefundUri(s: string): RefundUriResult | undefined { return undefined; } - const path = s.slice(pfx.length); + const [path, search] = s.slice(pfx.length).split("?"); let [host, maybePath, maybeInstance, orderId] = path.split("/"); @@ -236,10 +235,14 @@ export function parseRefundUri(s: string): RefundUriResult | undefined { maybeInstancePath = `instances/${maybeInstance}/`; } - const merchantBaseUrl = "https://" + host + - "/" + - maybePath + - maybeInstancePath + let protocol = "https"; + const searchParams = new URLSearchParams(search); + if (searchParams.get("insecure") === "1") { + protocol = "http"; + } + + const merchantBaseUrl = + `${protocol}://${host}/` + maybePath + maybeInstancePath; return { merchantBaseUrl, |