allow http for taler withdraw URIs
This commit is contained in:
parent
ae111663f4
commit
a4f1127e0a
@ -107,6 +107,17 @@ test("taler withdraw uri parsing", (t) => {
|
|||||||
t.is(r1.bankIntegrationApiBaseUrl, "https://bank.example.com/");
|
t.is(r1.bankIntegrationApiBaseUrl, "https://bank.example.com/");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("taler withdraw uri parsing (http)", (t) => {
|
||||||
|
const url1 = "taler+http://withdraw/bank.example.com/12345";
|
||||||
|
const r1 = parseWithdrawUri(url1);
|
||||||
|
if (!r1) {
|
||||||
|
t.fail();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
t.is(r1.withdrawalOperationId, "12345");
|
||||||
|
t.is(r1.bankIntegrationApiBaseUrl, "http://bank.example.com/");
|
||||||
|
});
|
||||||
|
|
||||||
test("taler refund uri parsing", (t) => {
|
test("taler refund uri parsing", (t) => {
|
||||||
const url1 = "taler://refund/merchant.example.com/1234";
|
const url1 = "taler://refund/merchant.example.com/1234";
|
||||||
const r1 = parseRefundUri(url1);
|
const r1 = parseRefundUri(url1);
|
||||||
|
@ -40,13 +40,11 @@ export interface TipUriResult {
|
|||||||
* Return undefined if not passed a valid URI.
|
* Return undefined if not passed a valid URI.
|
||||||
*/
|
*/
|
||||||
export function parseWithdrawUri(s: string): WithdrawUriResult | undefined {
|
export function parseWithdrawUri(s: string): WithdrawUriResult | undefined {
|
||||||
const pfx = "taler://withdraw/";
|
const pi = parseProtoInfo(s, "withdraw");
|
||||||
if (!s.toLowerCase().startsWith(pfx)) {
|
if (!pi) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
const parts = pi.rest.split("/");
|
||||||
const rest = s.substring(pfx.length);
|
|
||||||
const parts = rest.split("/");
|
|
||||||
|
|
||||||
if (parts.length < 2) {
|
if (parts.length < 2) {
|
||||||
return undefined;
|
return undefined;
|
||||||
@ -58,7 +56,7 @@ export function parseWithdrawUri(s: string): WithdrawUriResult | undefined {
|
|||||||
const p = [host, ...pathSegments].join("/");
|
const p = [host, ...pathSegments].join("/");
|
||||||
|
|
||||||
return {
|
return {
|
||||||
bankIntegrationApiBaseUrl: `https://${p}/`,
|
bankIntegrationApiBaseUrl: `${pi.innerProto}://${p}/`,
|
||||||
withdrawalOperationId: withdrawId,
|
withdrawalOperationId: withdrawId,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user