Skip to content

bowbahdoe/urlparameters

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

urlparameters

javadoc

Utility for parsing url parameters.

Dependency Information

Maven

<dependency>
    <groupId>dev.mccue</groupId>
    <artifactId>urlparameters</artifactId>
    <version>2024.01.05</version>
</dependency>

Gradle

dependencies {
    implementation("dev.mccue:urlparameters:2024.01.05")
}

Usage

Reading Parameters

// Get this string from a form submit or the query params on a URI.
var params = UrlParameters.parse("name=bob&age=44");
System.out.println(params.firstValue("name"));
// Optional[bob]
System.out.println(params.firstValue("age"));
// Optional[44]
System.out.println(params.firstValue("hair"));
// Optional.empty
        
// Or directly from a URI
var params2 = UrlParameters.parse(URI.create("https://example.com/path?name=bob&age=44"));
System.out.println(params2.firstValue("name"));
System.out.println(params2.firstValue("age"));
System.out.println(params2.firstValue("hair"));

Writing Parameters

var params = new UrlParameters(List.of(
    new UrlParameter("message", "hello world"),
    new UrlParameter("time", "now")
));

System.out.println(params);
// message=hello%20world&time=now

About

Utility for parsing url parameters

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages