https://github.com/coditory/quark-uri
URI manipulation library for Java
https://github.com/coditory/quark-uri
coditory-quark java-uri
Last synced: 2 months ago
JSON representation
URI manipulation library for Java
- Host: GitHub
- URL: https://github.com/coditory/quark-uri
- Owner: coditory
- License: mit
- Created: 2023-01-13T22:16:38.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2026-01-19T19:34:06.000Z (3 months ago)
- Last Synced: 2026-01-20T01:20:17.388Z (3 months ago)
- Topics: coditory-quark, java-uri
- Language: Java
- Homepage:
- Size: 263 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# Quark URI
[](https://github.com/coditory/quark-uri/actions/workflows/build.yml)
[](https://codecov.io/github/coditory/quark-uri)
[](https://mvnrepository.com/artifact/com.coditory.quark/quark-uri)
**🚧 This library as under heavy development until release of version `1.x.x` 🚧**
> Just a URI manipulation library for Java. Provides URI builder and parser.
- lightweight, exactly 1 minimalistic dependency
- single purpose, not part of a framework
- does percent encoding and decoding
- adds option to encode/decode `+` character as a space
## Installation
Add to your `build.gradle`:
```gradle
dependencies {
implementation "com.coditory.quark:quark-uri:0.0.11"
}
```
## Basic usage
Build uri string
```java
UriBuilder.fromUri("https://coditory.com?w=W&a=A")
.addPathSegment("about")
.addQueryParam("a", "X")
.addQueryParam("a", "X")
.addQueryParam("a", "Y")
.addQueryParam("b", "Y")
.addQueryParam("e", "")
.buildUriString();
// Result:
// https://coditory.com/about?w=W&a=A&a=X&a=X&a=Y&b=Y&e=
```
Build uri components
```java
// uriComponents is a value object, that provides access to all parts of parsed uri
UriComponents uriComponents = UriBuilder.fromUri("https://coditory.com?w=W&a=A")
.addPathSegment("about")
.addQueryParam("a", "X")
.addQueryParam("a", "X")
.addQueryParam("a", "Y")
.addQueryParam("b", "Y")
.addQueryParam("e", "")
.buildUriComponents();
// Result:
// UriComponents{scheme="https", host="coditory.com", pathSegments=[about], queryParams={w=[W], a=[A, X, X, Y], b=[Y], e=[]}}
```
Parses encoded spaces and pluses:
```java
UriComponents plusesAsSpaces = UriBuilder.fromUri("/abc?a+b=A+B").buildUriComponents();
UriComponents encodedSpaces = UriBuilder.fromUri("/abc?a%20b=A%20B").buildUriComponents();
assert plusesAsSpaces == encodedSpaces
// Result:
// UriComponents{rootPath=true, pathSegments=[abc], queryParams={a b=[A B]}}
```
By default encodes spaces as `%20`
```java
UriBuilder.fromUri("https://coditory.com/a+bc/d%20ef/")
.addPathSegment("x y ")
.setFragment("frag ment")
.addQueryParam("f oo", "b ar")
.addQueryParam("x", "y+z")
.buildUriString();
// Result:
// https://coditory.com/a+bc/d%20ef/x%20y%20?f%20oo=b%20ar&x=y%2Bz#frag%20ment
```