Skip to content

Commit

Permalink
Fix URLs if misconfigured.
Browse files Browse the repository at this point in the history
  • Loading branch information
paragonie-security committed Jan 20, 2018
1 parent f70a11b commit 331d730
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/Quill.php
Original file line number Diff line number Diff line change
Expand Up @@ -287,10 +287,22 @@ public function write(string $data): ResponseInterface
$this->assertValid();
$sapient = new Sapient(new Guzzle($this->http));

$url = $this->chronicleUrl;
$pieces = \explode('/', \trim($this->chronicleUrl, '/'));
$last = \array_pop($pieces);
if ($last !== 'publish') {
$precursor = \array_pop($pieces);
if ($precursor === 'chronicle') {
$url = $this->chronicleUrl . '/publish';
} else {
$url = $this->chronicleUrl . '/chronicle/publish';
}
}

/** @var Request $request */
$request = $sapient->createSignedRequest(
'POST',
$this->chronicleUrl,
$url,
$data,
$this->clientSSK,
[
Expand Down

0 comments on commit 331d730

Please sign in to comment.