A Kotlin Multi-platform Utility Library
for Uniform Resource Identifiers (URIs).
Uri.fromString("https://[email protected]:123/forum/questions/?tag=networking&order=newest#top")
Consider the following Uri: https://[email protected]:123/forum/questions/?tag=networking&order=newest#top
Uri.fromParts(
scheme = "https",
fragment = "top",
path = "/forum/questions/",
query = "tag=networking&order=newest",
userInfo = "john.doe",
host = "www.example.com",
port = 123
)
If an error is encountered with the Uri.fromParts
function, then an exception is thrown. Instead of throwing an
exception, null can be returned, using the Uri.fromPartsOrNull
function.
Uri.fromPartsOrNull(
scheme = "https",
fragment = "top",
path = "/forum/questions/",
query = "tag=networking&order=newest",
userInfo = "john.doe",
host = "www.example.com",
port = 123
)
This library has a typealias, UriString
, which is just a String
. A UriString
can be parsed and turned into a Uri
.
Uri.fromString(uriString = "https://[email protected]:123/forum/questions/?tag=networking&order=newest#top")
If an error is encountered with the Uri.fromString
function, then an exception is thrown. Instead of throwing an
exception, null can be returned, using the Uri.fromStringOrNull
function.
Uri.fromStringOrNull(uriString = "https://[email protected]:123/forum/questions/?tag=networking&order=newest#top")
The library is provided through Repsy.io. Refer to
the releases page for the latest version.
repositories {
maven { url = "https://repo.repsy.io/mvn/chrynan/public" }
}
implementation("com.chrynan.uri:uri-core:$VERSION")
implementation("com.chrynan.uri:uri-ktor-client:$VERSION")
More detailed documentation is available in the docs folder. The entry point to the documentation can be found here.
Copyright 2021 chRyNaN
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.