Skip to content

Commit

Permalink
Join subdir to base pj URL to preserve path
Browse files Browse the repository at this point in the history
Fix payjoin#416

Without this change a base URL subpath e.g. https://payjo.in/dir-path/
would be overwritten when V2Context.extract_req was called and
incorrectly produce a request to https://payjo.in/subdir instead of
https://payjo.in/dir-path/subdir.
  • Loading branch information
DanGould committed Dec 29, 2024
1 parent f7cb8b7 commit 0a35d3c
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions payjoin/src/send/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -411,12 +411,14 @@ 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(|e| InternalCreateRequestError::Url(e))?;

let body = encrypt_message_a(
Vec::new(),
&self.hpke_ctx.reply_pair.public_key().clone(),
Expand Down

0 comments on commit 0a35d3c

Please sign in to comment.