From 50091a5f85416e46bfbc526fb1bf886c64b51372 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Tue, 2 Apr 2024 12:48:59 +0200 Subject: wallet-core: fix logic bug in taler:// URI parsing --- packages/taler-util/src/taleruri.ts | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'packages/taler-util') diff --git a/packages/taler-util/src/taleruri.ts b/packages/taler-util/src/taleruri.ts index b56295c3f..0022a72cc 100644 --- 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, }); -- cgit v1.2.3