Skip to content

Commit

Permalink
Improve stripUrl regex (#443)
Browse files Browse the repository at this point in the history
* improve url regex

* improve url regex

---------

Co-authored-by: Arnau Mora Gras <[email protected]>
  • Loading branch information
Blaubeeree and ArnyminerZ authored Oct 3, 2024
1 parent db68a9b commit 29a78c7
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion app/src/main/java/at/bitfire/icsdroid/UriUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ object UriUtils {
* @throws IllegalArgumentException if no URL is found in the string
*/
fun String.stripUrl(): String? {
return "([a-zA-Z]+)://(\\w+)(.\\w+)*[\\w.&?=*]*".toRegex()
// schema host port path query
return ("([a-zA-Z]+://)" + "([\\w.]+)" + "(:\\d+)?" + "([\\w/]+)?" + "(\\?[\\w.&=*]*)?")
.toRegex()
.find(this)
?.value
}
Expand Down

0 comments on commit 29a78c7

Please sign in to comment.