Skip to content

Commit

Permalink
Be less stupid.
Browse files Browse the repository at this point in the history
It's amazing what you find once you dogfood.
  • Loading branch information
e3ndr committed Nov 15, 2024
1 parent fb1642a commit 4c3956d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
3 changes: 3 additions & 0 deletions src/main/java/co/casterlabs/rhs/protocol/http/Query.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.net.URLDecoder;
import java.util.AbstractMap.SimpleImmutableEntry;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand All @@ -13,6 +14,8 @@
import lombok.NonNull;

public class Query extends CaseInsensitiveMultiMap<String> {
public static final Query EMPTY = new Query(Collections.emptyMap(), "");

public final String raw;

private Query(Map<String, List<String>> src, String raw) {
Expand Down
10 changes: 7 additions & 3 deletions src/main/java/co/casterlabs/rhs/protocol/http/SimpleUri.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,30 @@ public class SimpleUri {
public final String path;
public final Query query;

public final String raw;

public static SimpleUri from(String host, String pathAndQuery) {
int idx = pathAndQuery.indexOf('?');
if (idx == -1) {
return new SimpleUri(
host,
pathAndQuery,
Query.from("")
Query.EMPTY,
host + pathAndQuery
);
} else {
return new SimpleUri(
host,
pathAndQuery.substring(0, idx),
Query.from(pathAndQuery.substring(idx + 1))
Query.from(pathAndQuery.substring(idx + 1)),
host + pathAndQuery
);
}
}

@Override
public String toString() {
return this.host + this.path + '?' + this.query.raw;
return this.raw;
}

}

0 comments on commit 4c3956d

Please sign in to comment.