Giter Club home page Giter Club logo

uri's Introduction

uri

A Kotlin Multi-platform Utility Library for Uniform Resource Identifiers (URIs).
GitHub tag (latest by date)

Uri.fromString("https://[email protected]:123/forum/questions/?tag=networking&order=newest#top")

Using the library

Consider the following Uri: https://[email protected]:123/forum/questions/?tag=networking&order=newest#top

Creating a Uri:

Uri.fromParts(
    scheme = "https",
    fragment = "top",
    path = "/forum/questions/",
    query = "tag=networking&order=newest",
    userInfo = "john.doe",
    host = "www.example.com",
    port = 123
)

Creating an optional Uri:

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
)

Creating a Uri from a String:

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")

Creating an optional Uri from a String:

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")

Building

The library is provided through Repsy.io. Refer to the releases page for the latest version.
GitHub tag (latest by date)

Repository

repositories {
    maven { url = "https://repo.repsy.io/mvn/chrynan/public" }
}

Dependencies

implementation("com.chrynan.uri:uri-core:$VERSION")
implementation("com.chrynan.uri:uri-ktor-client:$VERSION")

Documentation

More detailed documentation is available in the docs folder. The entry point to the documentation can be found here.

License

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.

uri's People

Contributors

chrynan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

woren reedyuk

uri's Issues

Regex is unreliable on K/N

Describe the bug
The Kotlin/Native regex engine has known issues with stack overflowing, and as such is extremely unreliable on iOS in my testing. Here are some youtrack issues about it:

https://youtrack.jetbrains.com/issue/KT-35508/EXCBADACCESScode2-address0x16d8dbff0-crashes-on-iOS-when-using-a-sequence-from-map-etc
https://youtrack.jetbrains.com/issue/KT-39789/Segfault-in-KotlinNative-regex-interpreter
https://youtrack.jetbrains.com/issue/KT-46211/KotlinNative-Stack-overflow-crash-in-Regex-classes-with-simple-pattern-and-very-large-input
https://youtrack.jetbrains.com/issue/KT-53352/Native-iOS-Crash-when-using-regex-newSingleThreadContext

I ran into this in my own code, and was only able to workaround the crash by injecting a native regex implementation (i.e. using NSRegularExpression), but then I crashed when calling into this library since it uses Regex behind the scenes ๐Ÿ˜„

To Reproduce
Steps to reproduce the behavior:

val testing = "https://static01.nyt.com/images/2017/12/17/business/15NETVOTE2/merlin_131286365_4b8e35f3-0c1e-42e9-be51-a01c779456f7-facebookJumbo.jpg?year=2017&h=550&w=1050&s=a303fe833125a071cc3c33506af0bcb7c2ea7b8550c7a3e086a1421b2f9d7388&k=ZQJBKqZ0VN"

Uri.fromStringOrNull(testing)

Smartphone (please complete the following information):

  • iPhone 14 pro simulator running ios 16.0

Additional context
The youtrack mentions increasing stack size should help, but I was unable to get that to work in my testing. Maybe I wasn't doing it right though.

Really just opening this ticket for broader awareness. I'm not sure the best approach to fixing it other than possibly rewriting using native regex. The jetbrains team does not seem keen to fixing it on their end.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.