aboutsummaryrefslogtreecommitdiff
path: root/src/taleruri.ts
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2019-10-02 14:21:31 +0530
committerFlorian Dold <florian.dold@gmail.com>2019-10-02 14:22:26 +0530
commit3f6d3d186bf6960951b16eb1ffac160c5d02195d (patch)
tree6f41c8ce0b93099b8b6768fdf7a404853975fd18 /src/taleruri.ts
parente3a5dbfe32c639cbb7666362ea233032cda4b18e (diff)
downloadwallet-core-3f6d3d186bf6960951b16eb1ffac160c5d02195d.tar.xz
taler URI parsing
* add support for non-https taler://pay URIs * implement path prefix properly
Diffstat (limited to 'src/taleruri.ts')
-rw-r--r--src/taleruri.ts10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/taleruri.ts b/src/taleruri.ts
index 0d68621b9..0af5c4c95 100644
--- a/src/taleruri.ts
+++ b/src/taleruri.ts
@@ -61,6 +61,7 @@ export function parseWithdrawUri(s: string): WithdrawUriResult | undefined {
export function parsePayUri(s: string): PayUriResult | undefined {
const parsedUri = new URI(s);
+ const query: any = parsedUri.query(true);
if (parsedUri.scheme() === "http" || parsedUri.scheme() === "https") {
return {
downloadUrl: s,
@@ -96,7 +97,7 @@ export function parsePayUri(s: string): PayUriResult | undefined {
}
if (maybePath === "-") {
- maybePath = "";
+ maybePath = "public/";
} else {
maybePath = decodeURIComponent(maybePath) + "/";
}
@@ -105,8 +106,13 @@ export function parsePayUri(s: string): PayUriResult | undefined {
maybeInstancePath = `instances/${maybeInstance}/`;
}
+ let protocol = "https";
+ if (query["insecure"] === "1") {
+ protocol = "http";
+ }
+
const downloadUrl = new URI(
- "https://" + host + "/" + decodeURIComponent(maybePath) + maybeInstancePath + "public/proposal",
+ protocol + "://" + host + "/" + decodeURIComponent(maybePath) + maybeInstancePath + "proposal",
)
.addQuery({ order_id: orderId })
.href();