-
Notifications
You must be signed in to change notification settings - Fork 170
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix: Add Account fails when full server uri is used #805
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, although I really wish we didn't have to use regex for something like this, and could use a library.
@@ -1231,6 +1231,18 @@ fun scrollToPreviousParentComment( | |||
} | |||
} | |||
|
|||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Someone should really make a library for this, if its functionality isn't already included in URL.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perfect
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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