Fix: Add Account fails when full server uri is used#805
Conversation
…RL, removes the protocol and anything that may come after a :, a / or a ?. Closes LemmyNet#739
dessalines
left a comment
There was a problem hiding this comment.
LGTM, although I really wish we didn't have to use regex for something like this, and could use a library.
| } | ||
| } | ||
|
|
||
| /** |
There was a problem hiding this comment.
Someone should really make a library for this, if its functionality isn't already included in URL.
There was a problem hiding this comment.
But this is the java ecosystem, of course something like this exists already.
Patterns.WEB_URL.matcher(url).matches() // To check if a valid URL
println(URL("https://lemmy.ml").host) // lemmy.ml
twizmwazin
left a comment
There was a problem hiding this comment.
Let's use @MV-GH's solution
|
In some cases regex is being used because the links are metaverse links that aren't actually valid URLs, or at least I don't think they are valid. |
…ic to test the function without mocking.
|
I reworked the function but didn't ended up using Also I added Roboelectric to the project because I didn't see any other way to test my function without mocking. But I'm fairly new to using and writing unit tests to correct me if I was wrong using that package. |
|
Could you not use |
|
Yes, thanks! That worked! |
Implemented a function that extracts the host part from a URL, removes the protocol and anything that may come after a :, a / or a ?.
Closes #739