Improve stability of thumbnail url generation#79
Merged
Conversation
Signed-off-by: Claudio Cambra <developer@claudiocambra.com>
Signed-off-by: Claudio Cambra <developer@claudiocambra.com>
Signed-off-by: Claudio Cambra <developer@claudiocambra.com>
Signed-off-by: Claudio Cambra <developer@claudiocambra.com>
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR refactors the thumbnail URL generation to use modern URL-building APIs with availability checks and adds a unit test to validate the new logic.
- Switches from manual string concatenation to
URL.appending(components:)and query items on supported OS versions. - Provides a fallback string-based URL constructor for older OS versions.
- Introduces a unit test to verify the generated thumbnail URL.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| Tests/NextcloudFileProviderKitTests/ItemMetadataTests.swift | Adds a test (thumbnailUrlCorrect) to assert that thumbnailUrl(size:) produces the expected URL. |
| Sources/NextcloudFileProviderKit/Metadata/ItemMetadata.swift | Replaces legacy URL string building with appending(components:) and query items, guarded by an availability check. |
Comments suppressed due to low confidence (1)
Tests/NextcloudFileProviderKitTests/ItemMetadataTests.swift:21
- Add a complementary test case for
hasPreview == false(e.g. whenitem.hasPreviewisfalse) to ensurethumbnailUrl(size:)correctly returnsnil.
#expect(item.thumbnailUrl(size: .init(width: 250, height: 250)) == expectedUrl)
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #79 +/- ##
==========================================
+ Coverage 81.08% 81.24% +0.16%
==========================================
Files 62 63 +1
Lines 13505 13562 +57
==========================================
+ Hits 10951 11019 +68
+ Misses 2554 2543 -11 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.