bitfireAT / davx5-ose

DAVx⁵ is an open-source CalDAV/CardDAV suite and sync app for Android. You can also access your online files (WebDAV) with it.
https://www.davx5.com
GNU General Public License v3.0
1.25k stars 69 forks source link

Replace `DavUtils.lastSegmentOfUrl` by `UrlUtils.lastSegment` #767

Closed ArnyminerZ closed 2 weeks ago

ArnyminerZ commented 2 weeks ago

The PR should be in Draft state during development. As soon as it's finished, it should be marked as Ready for review and a reviewer should be chosen.

See also: Writing A Great Pull Request Description

Purpose

Replaces all the usages of the deprecated DavUtils.lastSegmentOfUrl by the extension function of Url (lastSegment()).

Short description

DavUtils.lastSegmentOfUrl may be removed if desired.

Checklist

ArnyminerZ commented 2 weeks ago

Also, since lastSegment doesn't have any parameters, I'd replace the function:

fun HttpUrl.lastSegment(): String =
    pathSegments.lastOrNull { it.isNotEmpty() } ?: "/"

by a variable

val HttpUrl.lastSegment: String
    get() = pathSegments.lastOrNull { it.isNotEmpty() } ?: "/"

At the end, for the Java conversion it's the same, but it's shorter to write 😅

rfc2822 commented 2 weeks ago

by a variable

Yes please do so :)