Skip to content

Commit 12c280b

Browse files
committed
Join subdir to base pj URL to preserve path
Fix payjoin#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.
1 parent f7cb8b7 commit 12c280b

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

payjoin/src/send/mod.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -411,12 +411,14 @@ impl V2GetContext {
411411
ohttp_relay: Url,
412412
) -> Result<(Request, ohttp::ClientResponse), CreateRequestError> {
413413
use crate::uri::UrlExt;
414-
let mut url = self.endpoint.clone();
414+
let base_url = self.endpoint.clone();
415415

416416
// TODO unify with receiver's fn subdir_path_from_pubkey
417417
let hash = sha256::Hash::hash(&self.hpke_ctx.reply_pair.public_key().to_compressed_bytes());
418418
let subdir: ShortId = hash.into();
419-
url.set_path(&subdir.to_string());
419+
let url = base_url.join(&subdir.to_string())
420+
.map_err(|e| InternalCreateRequestError::Url(e))?;
421+
420422
let body = encrypt_message_a(
421423
Vec::new(),
422424
&self.hpke_ctx.reply_pair.public_key().clone(),

0 commit comments

Comments
 (0)