CardDavUtilsTest.ktCardDavUtils: principal URL generation, URI normalization (stripping CardDAV prefixes), and contact ID extraction from VCF and photo file paths. These are core routing helpers for the CardDAV server implementation.CardDavUtils is a utility class providing static helper methods for the CardDAV protocol implementation. This test covers three key URL/path manipulation functions essential for CardDAV resource addressing.
PFUserDO().also { it.username = "joe" })Converts a resource URL path to the corresponding principal URL. In WebDAV/CardDAV, each user has a principal resource representing their identity. This method maps user collection URLs to principal URLs:
/carddav/users/... → /carddav/principals/users/joe//users/... → /principals/users/joe/The method strips URL suffixes (the ... represents trailing path segments) and rewrites users to principals/users/{username}. This is defined in RFC 3744 (WebDAV Access Control) and RFC 6352 (CardDAV).
Strips the CardDAV prefix from URIs, normalizing them to their base resource type:
/carddav/users/ → users/users/ → users/principals/ → principalsExtracts the numeric ProjectForge contact ID from various file path patterns:
/carddav/users/joe/ProjectForge-123.vcf → 123/carddav/photos/contact-123.jpg → 123/carddav/photos/contact-123.png → 123ProjectForge-{id} and contact-{id} patterns, enabling the server to map CardDAV resource URLs back to ProjectForge database IDs.
The test uses Kotlin's apply scope function pattern: PFUserDO().also { it.username = "joe" }. This creates a partially initialized PFUserDO with only the username set — sufficient for the URL generation methods which only need the username property.
868d6abb7 2025 -> 2026 63081666f Source file headers: 2024-> 2025. cc9abacea CardDav-Server: WIP: image handling. c4062ed97 WIP: Carddav 40e554cbe WIP: Carddav