Skip to content

Latest commit

 

History

History

kommons-uri

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

Kommons URI

About

Kommons URI is a Kotlin Multiplatform Library that offers:

  1. parsing and serializing Uniform Resource Identifiers (RFC3986)
  2. support for kotlinx.serialization
  3. support for data URIs (RFC2397) with an appropriate URL stream handler provider registered on the JVM

Installation / setup

This library is hosted on GitHub with releases provided on Maven Central.

  • Gradle implementation("com.bkahlert.kommons:kommons-uri:2.8.0")

  • Maven

    <dependency>
        <groupId>com.bkahlert.kommons</groupId>
        <artifactId>kommons-uri</artifactId>
        <version>2.8.0</version>
    </dependency>

Features

Multiplatform

// Parser
val uri = Uri.parse("https://username:[email protected]:8080/poo/par?qoo=qar&qaz#foo=far&faz")
val dataUri = Uri.parse("data:text/plain;charset=UTF-8;base64,ICEwQEF6e3x9fg")

// Extensions
val endpoint = uri / "path-segment"
// https://username:[email protected]:8080/poo/par/path-segment?qoo=qar&qaz#foo=far&faz

JVM

// Parser
val uri = URI("https://username:[email protected]:8080/poo/par?qoo=qar&qaz#foo=far&faz")
val dataUrl = URL("data:text/plain;charset=UTF-8;base64,ICEwQEF6e3x9fg")

// Extensions
val endpoint = uri / "path-segment" // same extensions on URI and URL
val decoded = dataUrl.openConnection().getInputStream().readBytes().decodeToString() // " !0@Az{|}~"
val decodedWithKotlin = dataUrl.readText() // " !0@Az{|}~" 

Contributing

Want to contribute? Awesome! The most basic way to show your support is to star the project or to raise issues. You can also support this project by making a PayPal donation to ensure this journey continues indefinitely!

Thanks again for your support, it's much appreciated! 🙏

License

MIT. See LICENSE for more details.