Skip to content

feat: encode and decode net/url.URL fields#860

Open
raeperd wants to merge 1 commit intogoccy:masterfrom
raeperd:feat/url-support
Open

feat: encode and decode net/url.URL fields#860
raeperd wants to merge 1 commit intogoccy:masterfrom
raeperd:feat/url-support

Conversation

@raeperd
Copy link
Copy Markdown

@raeperd raeperd commented Mar 24, 2026

Closes #859

  • Describe the purpose for which you created this PR.
  • Create test code that corresponds to the modification

Purpose

Add native encode/decode support for net/url.URL and *url.URL, following the existing time.Duration pattern (#201).

Changes

  • decode.go: Register *url.URL in canDecodeByUnmarshaler, add castToURL and decodeURL using url.Parse()
  • encode.go: Register url.URL and *url.URL in canEncodeByMarshaler, add encodeURL using url.URL.String()
  • Tests: Decode (value, pointer, null), encode (value, pointer, null), error cases (invalid URL string, int type mismatch)

Note on url.Parse vs url.ParseRequestURI

This implementation uses url.Parse(), which is permissive (accepts relative paths like /api/v1). If you'd prefer the stricter url.ParseRequestURI() (requires absolute URI with scheme), I'm happy to switch — just let me know.

Add native support for encoding and decoding url.URL and *url.URL,
following the existing time.Duration pattern.
@codecov-commenter
Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 76.47059% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.49%. Comparing base (d4021ff) to head (5ae5460).
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #860      +/-   ##
==========================================
- Coverage   80.51%   80.49%   -0.02%     
==========================================
  Files          22       22              
  Lines        6847     6881      +34     
==========================================
+ Hits         5513     5539      +26     
- Misses        913      917       +4     
- Partials      421      425       +4     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@raeperd raeperd marked this pull request as ready for review March 24, 2026 15:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature request: encode and decode net/url.URL fields

2 participants