taler-typescript-core

Wallet core logic and WebUIs for various components
Log | Files | Refs | Submodules | README | LICENSE

commit 50091a5f85416e46bfbc526fb1bf886c64b51372
parent 6a41dc3b8ae2799363e0301c10a5c6abee1e2b6f
Author: Florian Dold <florian@dold.me>
Date:   Tue,  2 Apr 2024 12:48:59 +0200

wallet-core: fix logic bug in taler:// URI parsing

Diffstat:
Mpackages/taler-util/src/taleruri.ts | 25+++++++++++++------------
1 file changed, 13 insertions(+), 12 deletions(-)

diff --git a/packages/taler-util/src/taleruri.ts b/packages/taler-util/src/taleruri.ts @@ -25,10 +25,10 @@ */ import { Codec, Context, DecodingError, renderContext } from "./codec.js"; import { canonicalizeBaseUrl } from "./helpers.js"; -import { AmountString } from "./taler-types.js"; -import { URL, URLSearchParams } from "./url.js"; import { opFixedSuccess, opKnownTalerFailure } from "./operation.js"; import { TalerErrorCode } from "./taler-error-codes.js"; +import { AmountString } from "./taler-types.js"; +import { URL, URLSearchParams } from "./url.js"; /** * A parsed taler URI. */ @@ -140,7 +140,7 @@ export function parseWithdrawUriWithError(s: string) { if (parts.length < 2) { return opKnownTalerFailure(TalerErrorCode.TALER_URI_NO_ENOUGH_COMPONENT, { - code: TalerErrorCode.TALER_URI_NO_ENOUGH_COMPONENT + code: TalerErrorCode.TALER_URI_NO_ENOUGH_COMPONENT, }); } @@ -158,14 +158,16 @@ export function parseWithdrawUriWithError(s: string) { const result: WithdrawUriResult = { type: TalerUriAction.Withdraw, - bankIntegrationApiBaseUrl: canonicalizeBaseUrl(`${pi.body.innerProto}://${p}/`), + bankIntegrationApiBaseUrl: canonicalizeBaseUrl( + `${pi.body.innerProto}://${p}/`, + ), withdrawalOperationId: withdrawId, - } + }; return opFixedSuccess(result); } /** - * + * * @deprecated use parseWithdrawUriWithError */ export function parseWithdrawUri(s: string): WithdrawUriResult | undefined { @@ -229,12 +231,11 @@ function parseProtoInfo( } } -function parseProtoInfoWithError( - s: string, - action: string, -) { - if (!s.toLocaleLowerCase().startsWith("taler://") || - !s.toLocaleLowerCase().startsWith("taler+http://")) { +function parseProtoInfoWithError(s: string, action: string) { + if ( + !s.toLowerCase().startsWith("taler://") && + !s.toLowerCase().startsWith("taler+http://") + ) { return opKnownTalerFailure(TalerErrorCode.TALER_URI_PREFIX, { code: TalerErrorCode.TALER_URI_PREFIX, });