From 13d72de82d6dd42b4191cea31a351193205f6eba Mon Sep 17 00:00:00 2001 From: Andrew Camilleri Date: Wed, 27 Feb 2019 12:25:13 +0100 Subject: [PATCH] fix payment request redirect url (#617) --- BTCPayServer/Controllers/PaymentRequestController.cs | 2 +- BTCPayServer/Extensions.cs | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/BTCPayServer/Controllers/PaymentRequestController.cs b/BTCPayServer/Controllers/PaymentRequestController.cs index 87947637a..aecf8b22a 100644 --- a/BTCPayServer/Controllers/PaymentRequestController.cs +++ b/BTCPayServer/Controllers/PaymentRequestController.cs @@ -295,7 +295,7 @@ namespace BTCPayServer.Controllers Price = amount.GetValueOrDefault(result.AmountDue), FullNotifications = true, BuyerEmail = result.Email, - RedirectURL = Request.GetDisplayUrl().Replace("/pay", "", StringComparison.InvariantCulture), + RedirectURL = Request.GetDisplayUrl().TrimEnd("/pay", StringComparison.InvariantCulture), }, store, HttpContext.Request.GetAbsoluteRoot(), new List() { PaymentRequestRepository.GetInternalTag(id) })).Data.Id; if (redirectToInvoice) diff --git a/BTCPayServer/Extensions.cs b/BTCPayServer/Extensions.cs index 0416b0c59..59e1372ea 100644 --- a/BTCPayServer/Extensions.cs +++ b/BTCPayServer/Extensions.cs @@ -315,5 +315,15 @@ namespace BTCPayServer var res = JsonConvert.SerializeObject(o, Formatting.None, jsonSettings); return res; } + + public static string TrimEnd(this string input, string suffixToRemove, + StringComparison comparisonType) { + + if (input != null && suffixToRemove != null + && input.EndsWith(suffixToRemove, comparisonType)) { + return input.Substring(0, input.Length - suffixToRemove.Length); + } + else return input; + } } }