mirror of
https://github.com/jlengrand/github-api.git
synced 2026-04-05 08:21:21 +00:00
Make withUrlPath() overwrite instead of append
I had some ideas about having multiple calls to apend to build up paths, but it turns out that idea is pretty bad. `with*()` methods should overwrite when called for the same field. If we want to create and , we can do that later.
This commit is contained in:
@@ -980,12 +980,13 @@ public class GHRepository extends GHObject {
|
||||
private void modifyCollaborators(@NonNull Collection<GHUser> users,
|
||||
@NonNull String method,
|
||||
@CheckForNull GHOrganization.Permission permission) throws IOException {
|
||||
Requester requester = root.createRequest().method(method);
|
||||
if (permission != null) {
|
||||
requester = requester.with("permission", permission).inBody();
|
||||
}
|
||||
|
||||
// Make sure that the users collection doesn't have any duplicates
|
||||
for (GHUser user : new LinkedHashSet<GHUser>(users)) {
|
||||
Requester requester = root.createRequest().method(method);
|
||||
if (permission != null) {
|
||||
requester = requester.with("permission", permission).inBody();
|
||||
}
|
||||
requester.withUrlPath(getApiTailUrl("collaborators/" + user.getLogin())).send();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -671,13 +671,9 @@ class GitHubRequest {
|
||||
tailUrlPath += "/" + String.join("/", urlPathItems);
|
||||
}
|
||||
|
||||
if (this.urlPath.endsWith("/")) {
|
||||
tailUrlPath = StringUtils.stripStart(tailUrlPath, "/");
|
||||
} else {
|
||||
tailUrlPath = StringUtils.prependIfMissing(tailUrlPath, "/");
|
||||
}
|
||||
tailUrlPath = StringUtils.prependIfMissing(tailUrlPath, "/");
|
||||
|
||||
this.urlPath += urlPathEncode(tailUrlPath);
|
||||
this.urlPath = urlPathEncode(tailUrlPath);
|
||||
return (B) this;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user