@@ -41,17 +41,20 @@ public function fetchFile($path, $revision = null)
41
41
return Promise \reject (new InvalidArgumentException ('File path MUST NOT end with trailing slash ' ));
42
42
}
43
43
44
- $ url = $ path . '?view=co ' ;
45
- if ($ revision !== null ) {
46
- $ url .= '&pathrev= ' . $ revision ;
47
- }
48
-
49
44
// TODO: fetching a directory redirects to path with trailing slash
50
45
// TODO: status returns 200 OK, but displays an error message anyways..
51
46
// TODO: see not-a-file.html
52
47
// TODO: reject all paths with trailing slashes
53
48
54
- return $ this ->fetch ($ url );
49
+ return $ this ->fetch (
50
+ $ this ->browser ->resolve (
51
+ '/{+path}?view=co{&pathrev} ' ,
52
+ array (
53
+ 'path ' => ltrim ($ path , '/ ' ),
54
+ 'pathrev ' => $ revision
55
+ )
56
+ )
57
+ );
55
58
}
56
59
57
60
public function fetchDirectory ($ path , $ revision = null , $ showAttic = false )
@@ -60,21 +63,19 @@ public function fetchDirectory($path, $revision = null, $showAttic = false)
60
63
return Promise \reject (new InvalidArgumentException ('Directory path MUST end with trailing slash ' ));
61
64
}
62
65
63
- $ url = $ path ;
64
-
65
- if ($ revision !== null ) {
66
- $ url .= '?pathrev= ' . $ revision ;
67
- }
68
-
69
- if ($ showAttic ) {
70
- $ url .= (strpos ($ url , '? ' ) === false ) ? '? ' : '& ' ;
71
- $ url .= 'hideattic=0 ' ;
72
- }
73
-
74
66
// TODO: path MUST end with trailing slash
75
67
// TODO: accessing files will redirect to file with relative location URL (not supported by clue/buzz-react)
76
68
77
- return $ this ->fetchXml ($ url )->then (function (SimpleXMLElement $ xml ) {
69
+ return $ this ->fetchXml (
70
+ $ this ->browser ->resolve (
71
+ '/{+path}{?pathrev,hideattic} ' ,
72
+ array (
73
+ 'path ' => ltrim ($ path , '/ ' ),
74
+ 'pathrev ' => $ revision ,
75
+ 'hideattic ' => $ showAttic ? '0 ' : null
76
+ )
77
+ )
78
+ )->then (function (SimpleXMLElement $ xml ) {
78
79
// TODO: reject if this is a file, instead of directory => contains "Log of" instead of "Index of"
79
80
// TODO: see is-a-file.html
80
81
@@ -84,23 +85,31 @@ public function fetchDirectory($path, $revision = null, $showAttic = false)
84
85
85
86
public function fetchPatch ($ path , $ r1 , $ r2 )
86
87
{
87
- $ url = $ path . '?view=patch&r1= ' . $ r1 . '&r2= ' . $ r2 ;
88
-
89
- return $ this ->fetch ($ url );
88
+ return $ this ->fetch (
89
+ $ this ->browser ->resolve (
90
+ '/{+path}?view=patch{&r1,r2} ' ,
91
+ array (
92
+ 'path ' => ltrim ($ path , '/ ' ),
93
+ 'r1 ' => $ r1 ,
94
+ 'r2 ' => $ r2
95
+ )
96
+ )
97
+ );
90
98
}
91
99
92
100
public function fetchLog ($ path , $ revision = null )
93
101
{
94
- $ url = $ path . '?view=log ' ;
95
-
96
102
// TODO: invalid revision shows error page, but HTTP 200 OK
97
103
98
- if ($ revision !== null ) {
99
- $ url .= (strpos ($ url , '? ' ) === false ) ? '? ' : '& ' ;
100
- $ url .= 'pathrev= ' . $ revision ;
101
- }
102
-
103
- return $ this ->fetchXml ($ url )->then (array ($ this ->parser , 'parseLogEntries ' ));
104
+ return $ this ->fetchXml (
105
+ $ this ->browser ->resolve (
106
+ '/{+path}?view=log{&pathrev} ' ,
107
+ array (
108
+ 'path ' => ltrim ($ path , '/ ' ),
109
+ 'pathrev ' => $ revision
110
+ )
111
+ )
112
+ )->then (array ($ this ->parser , 'parseLogEntries ' ));
104
113
}
105
114
106
115
public function fetchRevisionPrevious ($ path , $ revision )
@@ -121,9 +130,14 @@ public function fetchAllPreviousRevisions($path)
121
130
122
131
private function fetchLogXml ($ path )
123
132
{
124
- $ url = $ path . '?view=log ' ;
125
-
126
- return $ this ->fetchXml ($ url );
133
+ return $ this ->fetchXml (
134
+ $ this ->browser ->resolve (
135
+ '/{+path}?view=log ' ,
136
+ array (
137
+ 'path ' => ltrim ($ path , '/ ' )
138
+ )
139
+ )
140
+ );
127
141
}
128
142
129
143
private function fetchXml ($ url )
@@ -133,7 +147,7 @@ private function fetchXml($url)
133
147
134
148
private function fetch ($ url )
135
149
{
136
- return $ this ->browser ->get (ltrim ( $ url, ' / ' ) )->then (
150
+ return $ this ->browser ->get ($ url )->then (
137
151
function (Response $ response ) {
138
152
return (string )$ response ->getBody ();
139
153
},
0 commit comments