diff options
author | MS <ms@taler.net> | 2023-03-09 16:45:32 +0100 |
---|---|---|
committer | MS <ms@taler.net> | 2023-03-09 16:45:32 +0100 |
commit | 325b16de31568310d48fad2409dd8752dc4b3ac1 (patch) | |
tree | 329c941bb5d40d6ea7dd186965b2b12f5d60a514 /sandbox/src/main/kotlin/tech/libeufin | |
parent | eb734259ce107e8850e4f50c881be91847e5778c (diff) | |
download | libeufin-325b16de31568310d48fad2409dd8752dc4b3ac1.tar.gz libeufin-325b16de31568310d48fad2409dd8752dc4b3ac1.tar.bz2 libeufin-325b16de31568310d48fad2409dd8752dc4b3ac1.zip |
fix Taler withdraw URI formation
Diffstat (limited to 'sandbox/src/main/kotlin/tech/libeufin')
-rw-r--r-- | sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt index 70294e80..1f02728c 100644 --- a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt +++ b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt @@ -1325,24 +1325,28 @@ val sandboxApp: Application.() -> Unit = { -1 ) host = "withdraw" - this.appendPathSegments( - listOf( - /** - * encodes the hostname(+port) of the actual - * bank that will serve the withdrawal request. - */ - baseUrl.host.plus( - if (baseUrl.port != -1) - ":${baseUrl.port}" - else "" - ), - baseUrl.path, // has x-forwarded-prefix, or single slash. - "demobanks", - demobank.name, - "integration-api", - wo.wopid.toString() + val pathSegments = mutableListOf( + /** + * encodes the hostname(+port) of the actual + * bank that will serve the withdrawal request. + */ + baseUrl.host.plus( + if (baseUrl.port != -1) + ":${baseUrl.port}" + else "" ) ) + /** + * Slashes can only be intermediate and single, + * any other combination results in badly formed URIs. + * The following loop ensure this for the current URI path. + * This might even come from X-Forwarded-Prefix. + */ + baseUrl.path.split("/").forEach { + if (it.isNotEmpty()) pathSegments.add(it) + } + pathSegments.add("demobanks/${demobank.name}/integration-api/${wo.wopid}") + this.appendPathSegments(pathSegments) } call.respond(object { val withdrawal_id = wo.wopid.toString() |