Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions src/main/java/org/lightcouch/URIBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,19 @@ public URIBuilder path(String path, boolean encode) {
}

public URIBuilder query(String name, Object value) {
if (name != null && value != null)
this.qParams.add(String.format("%s=%s", name, value));
String qPV = String.format("%s=%s", name, value);
if (name != null && value != null) {
for(int i = 0; i < this.qParams.size(); ++i) {
String[] tokens = this.qParams.get(i).split("=");
if(tokens != null && tokens.length > 0) {
if(tokens[0].compareTo(name) == 0) {
this.qParams.set(i, qPV);
return this;
}
}
}
this.qParams.add(qPV);
}
return this;
}

Expand Down Expand Up @@ -133,6 +144,7 @@ private URI createUriEncoded() {
}

private void prepareQuery() {
query.delete(0, query.length());
for (int i = 0; i < qParams.size(); i++) {
String amp = (i != qParams.size() - 1) ? "&" : "";
query.append(qParams.get(i) + amp);
Expand Down