From df9c5b8c707c8ef1948bff02099546ffc5919d92 Mon Sep 17 00:00:00 2001 From: DanGould Date: Sun, 29 Dec 2024 12:02:40 -0500 Subject: [PATCH] Join subdir to base pj URL to preserve path Fix #416 Without this change a base URL subpath e.g. https://payjo.in/dir-path/ would be overwritten when V2GetContext.extract_req was called and incorrectly produce a request to https://payjo.in/subdir instead of https://payjo.in/dir-path/subdir. --- payjoin/src/send/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/payjoin/src/send/mod.rs b/payjoin/src/send/mod.rs index af62eaf0..339c5755 100644 --- a/payjoin/src/send/mod.rs +++ b/payjoin/src/send/mod.rs @@ -411,12 +411,12 @@ impl V2GetContext { ohttp_relay: Url, ) -> Result<(Request, ohttp::ClientResponse), CreateRequestError> { use crate::uri::UrlExt; - let mut url = self.endpoint.clone(); + let base_url = self.endpoint.clone(); // TODO unify with receiver's fn subdir_path_from_pubkey let hash = sha256::Hash::hash(&self.hpke_ctx.reply_pair.public_key().to_compressed_bytes()); let subdir: ShortId = hash.into(); - url.set_path(&subdir.to_string()); + let url = base_url.join(&subdir.to_string()).map_err(InternalCreateRequestError::Url)?; let body = encrypt_message_a( Vec::new(), &self.hpke_ctx.reply_pair.public_key().clone(),