@@ -41,17 +41,20 @@ public function fetchFile($path, $revision = null)
4141 return Promise \reject (new InvalidArgumentException ('File path MUST NOT end with trailing slash ' ));
4242 }
4343
44- $ url = $ path . '?view=co ' ;
45- if ($ revision !== null ) {
46- $ url .= '&pathrev= ' . $ revision ;
47- }
48-
4944 // TODO: fetching a directory redirects to path with trailing slash
5045 // TODO: status returns 200 OK, but displays an error message anyways..
5146 // TODO: see not-a-file.html
5247 // TODO: reject all paths with trailing slashes
5348
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+ );
5558 }
5659
5760 public function fetchDirectory ($ path , $ revision = null , $ showAttic = false )
@@ -60,21 +63,19 @@ public function fetchDirectory($path, $revision = null, $showAttic = false)
6063 return Promise \reject (new InvalidArgumentException ('Directory path MUST end with trailing slash ' ));
6164 }
6265
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-
7466 // TODO: path MUST end with trailing slash
7567 // TODO: accessing files will redirect to file with relative location URL (not supported by clue/buzz-react)
7668
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 ) {
7879 // TODO: reject if this is a file, instead of directory => contains "Log of" instead of "Index of"
7980 // TODO: see is-a-file.html
8081
@@ -84,23 +85,31 @@ public function fetchDirectory($path, $revision = null, $showAttic = false)
8485
8586 public function fetchPatch ($ path , $ r1 , $ r2 )
8687 {
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+ );
9098 }
9199
92100 public function fetchLog ($ path , $ revision = null )
93101 {
94- $ url = $ path . '?view=log ' ;
95-
96102 // TODO: invalid revision shows error page, but HTTP 200 OK
97103
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 ' ));
104113 }
105114
106115 public function fetchRevisionPrevious ($ path , $ revision )
@@ -121,9 +130,14 @@ public function fetchAllPreviousRevisions($path)
121130
122131 private function fetchLogXml ($ path )
123132 {
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+ );
127141 }
128142
129143 private function fetchXml ($ url )
@@ -133,7 +147,7 @@ private function fetchXml($url)
133147
134148 private function fetch ($ url )
135149 {
136- return $ this ->browser ->get (ltrim ( $ url, ' / ' ) )->then (
150+ return $ this ->browser ->get ($ url )->then (
137151 function (Response $ response ) {
138152 return (string )$ response ->getBody ();
139153 },
0 commit comments