mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-07-13 00:52:01 -04:00
Codacy flagged the colon-path middleware comment claiming both `$` and `!` need percent-encoding for chi's tree match, while the implementation only calls r.URL.RawPath = r.URL.EscapedPath() which does not encode either character per the suggestion's reading. In practice EscapedPath does encode `!` as `%21` (only `?` is the hardcoded escape, `!` is escaped because Go's net/url treats it as needing encoding outside specific contexts). It leaves `$` literal, which chi handles fine. chi.URLParam returns the encoded segment verbatim, and downstream OpenCloud handlers (parseIDParam, GetDriveAndItemIDParam) already PathUnescape before parsing IDs, so the round-trip works end-to-end. The acceptance tests on this branch already exercise this with real `$`/`!`-containing IDs. Add a focused unit test that mounts the middleware behind chi, sends a colon URL, and asserts the actual contract: - driveID (only `$`): chi.URLParam returns it literal - itemID (with `!`): PathUnescape(chi.URLParam(...)) == original Update the misleading comment so future readers (and reviewers) see what the encoding actually does and which downstream contract it relies on.