Skip to content
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

Replace DavUtils.lastSegmentOfUrl by UrlUtils.lastSegment #767

Merged

Conversation

ArnyminerZ
Copy link
Member

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

  • Added replaceWith to the annotation.
  • Replaced all usages

DavUtils.lastSegmentOfUrl may be removed if desired.

Checklist

  • The PR has a proper title, description and label.
  • I have self-reviewed the PR.
  • I have added documentation to complex functions and functions that can be used by other modules.
  • I have added reasonable tests or consciously decided to not add tests.

Signed-off-by: Arnau Mora Gras <[email protected]>
@ArnyminerZ ArnyminerZ linked an issue Apr 30, 2024 that may be closed by this pull request
Signed-off-by: Arnau Mora Gras <[email protected]>
@ArnyminerZ ArnyminerZ marked this pull request as ready for review April 30, 2024 11:04
@ArnyminerZ ArnyminerZ requested a review from rfc2822 April 30, 2024 11:04
Copy link
Member

@rfc2822 rfc2822 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. We can already remove the DavUtils.lastSegmentOfUrl.

Then the tests DavUtils.lastSegmentOfUrl for will also have to be moved into UrlUtilsTest and testHttpUrl_lastSegment

@ArnyminerZ
Copy link
Member Author

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 😅

@ArnyminerZ ArnyminerZ self-assigned this Apr 30, 2024
@ArnyminerZ ArnyminerZ requested a review from rfc2822 April 30, 2024 14:14
@rfc2822 rfc2822 added the refactoring Internal improvement of existing functions label May 2, 2024
@rfc2822
Copy link
Member

rfc2822 commented May 2, 2024

by a variable

Yes please do so :)

Copy link
Member

@rfc2822 rfc2822 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test still fail, probably some minimal thing

@rfc2822 rfc2822 force-pushed the main-ose branch 12 times, most recently from 3c18f50 to 5317294 Compare May 2, 2024 11:46
@rfc2822 rfc2822 force-pushed the main-ose branch 5 times, most recently from 47ef18b to 39f8f2e Compare May 2, 2024 12:03
@ArnyminerZ ArnyminerZ requested a review from rfc2822 May 2, 2024 13:22
Copy link
Member

@rfc2822 rfc2822 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still fails

Signed-off-by: Arnau Mora <[email protected]>
@ArnyminerZ ArnyminerZ requested a review from rfc2822 May 3, 2024 06:39
@rfc2822 rfc2822 merged commit a7c04c2 into main-ose May 3, 2024
7 checks passed
@rfc2822 rfc2822 deleted the 761-replace-davutilslastsegmentofurl-by-urlutilslastsegment branch May 3, 2024 09:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactoring Internal improvement of existing functions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Replace DavUtils.lastSegmentOfUrl by UrlUtils.lastSegment
2 participants