File tree Expand file tree Collapse file tree 1 file changed +12
-7
lines changed
Filter options
src/main/java/org/kohsuke/github Expand file tree Collapse file tree 1 file changed +12
-7
lines changed
Original file line number Diff line number Diff line change 45
45
import java .util .Iterator ;
46
46
import java .util .LinkedHashMap ;
47
47
import java .util .List ;
48
+ import java .util .ListIterator ;
48
49
import java .util .Locale ;
49
50
import java .util .Map ;
50
51
import java .util .NoSuchElementException ;
@@ -219,15 +220,19 @@ public <T> T to(String tailApiUrl, Class<T> type, String method) throws IOExcept
219
220
}
220
221
221
222
private <T > T _to (String tailApiUrl , Class <T > type , T instance ) throws IOException {
222
- while (true ) {// loop while API rate limit is hit
223
- if (METHODS_WITHOUT_BODY .contains (method ) && !args .isEmpty ()) {
224
- StringBuilder qs =new StringBuilder ();
225
- for (Entry arg : args ) {
226
- qs .append (qs .length ()==0 ? '?' : '&' );
227
- qs .append (arg .key ).append ('=' ).append (URLEncoder .encode (arg .value .toString (),"UTF-8" ));
223
+ if (METHODS_WITHOUT_BODY .contains (method ) && !args .isEmpty ()) {
224
+ boolean questionMarkFound = tailApiUrl .indexOf ('?' ) != -1 ;
225
+ tailApiUrl += questionMarkFound ? '&' : '?' ;
226
+ for (Iterator <Entry > it = args .listIterator (); it .hasNext ();) {
227
+ Entry arg = it .next ();
228
+ tailApiUrl += arg .key + '=' + URLEncoder .encode (arg .value .toString (),"UTF-8" );
229
+ if (it .hasNext ()) {
230
+ tailApiUrl += '&' ;
228
231
}
229
- tailApiUrl += qs .toString ();
230
232
}
233
+ }
234
+
235
+ while (true ) {// loop while API rate limit is hit
231
236
setupConnection (root .getApiURL (tailApiUrl ));
232
237
233
238
buildRequest ();
You can’t perform that action at this time.
0 commit comments