Skip to content

Commit 98b7e59

Browse files
committed
Depend on rize/uri-template to expand all URIs
1 parent 5e582b8 commit 98b7e59

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
"react/promise": "~2.1|~1.1",
2020
"clue/buzz-react": "~0.4.1",
2121
"ext-simplexml": "*",
22-
"neitanod/forceutf8": "~1.4"
22+
"neitanod/forceutf8": "~1.4",
23+
"rize/uri-template": "^0.3"
2324
},
2425
"require-dev": {
2526
"clue/block-react": "~0.3.0"

src/Client.php

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,26 @@
1111
use React\Promise;
1212
use Clue\React\ViewVcApi\Io\Parser;
1313
use Clue\React\ViewVcApi\Io\Loader;
14+
use Rize\UriTemplate;
1415

1516
class Client
1617
{
1718
private $brower;
19+
private $parser;
20+
private $loader;
21+
private $uri;
1822

19-
public function __construct(Browser $browser, Parser $parser = null, Loader $loader = null)
23+
public function __construct(Browser $browser, Parser $parser = null, Loader $loader = null, UriTemplate $uri = null)
2024
{
2125
if ($parser === null) {
2226
$parser = new Parser();
2327
}
2428
if ($loader === null) {
2529
$loader = new Loader();
2630
}
31+
if ($uri === null) {
32+
$uri = new UriTemplate();
33+
}
2734

2835
// TODO: do not follow redirects
2936
// $browser = $this->browser->withOptions(array(
@@ -33,6 +40,7 @@ public function __construct(Browser $browser, Parser $parser = null, Loader $loa
3340
$this->browser = $browser;
3441
$this->parser = $parser;
3542
$this->loader = $loader;
43+
$this->uri = $uri;
3644
}
3745

3846
public function fetchFile($path, $revision = null)
@@ -47,7 +55,7 @@ public function fetchFile($path, $revision = null)
4755
// TODO: reject all paths with trailing slashes
4856

4957
return $this->fetch(
50-
$this->browser->resolve(
58+
$this->uri->expand(
5159
'{+path}?view=co{&pathrev}',
5260
array(
5361
'path' => $path,
@@ -67,7 +75,7 @@ public function fetchDirectory($path, $revision = null, $showAttic = false)
6775
// TODO: accessing files will redirect to file with relative location URL (not supported by clue/buzz-react)
6876

6977
return $this->fetchXml(
70-
$this->browser->resolve(
78+
$this->uri->expand(
7179
'{+path}{?pathrev,hideattic}',
7280
array(
7381
'path' => $path,
@@ -86,7 +94,7 @@ public function fetchDirectory($path, $revision = null, $showAttic = false)
8694
public function fetchPatch($path, $r1, $r2)
8795
{
8896
return $this->fetch(
89-
$this->browser->resolve(
97+
$this->uri->expand(
9098
'{+path}?view=patch{&r1,r2}',
9199
array(
92100
'path' => $path,
@@ -102,7 +110,7 @@ public function fetchLog($path, $revision = null)
102110
// TODO: invalid revision shows error page, but HTTP 200 OK
103111

104112
return $this->fetchXml(
105-
$this->browser->resolve(
113+
$this->uri->expand(
106114
'{+path}?view=log{&pathrev}',
107115
array(
108116
'path' => $path,
@@ -131,7 +139,7 @@ public function fetchAllPreviousRevisions($path)
131139
private function fetchLogXml($path)
132140
{
133141
return $this->fetchXml(
134-
$this->browser->resolve(
142+
$this->uri->expand(
135143
'{+path}?view=log',
136144
array(
137145
'path' => $path

0 commit comments

Comments
 (0)