Component-Specific Percent-Encoding

Summary

Implement component-specific encoding rules in percentEncode().

Currently the component parameter is ignored.

Current State

pub fn percentEncode(allocator: Allocator, input: []const u8, component: Component) ... {
    _ = component; // TODO: Component-specific encoding rules
    // Uses generic unreserved character set
}

Requirements

Per RFC 3986, different components allow different characters:

  • Scheme: ALPHA / DIGIT / "+" / "-" / "."
  • Userinfo: unreserved / pct-encoded / sub-delims / ":"
  • Host: reg-name allows unreserved / pct-encoded / sub-delims
  • Path: pchar / "/"
  • Query: pchar / "/" / "?"
  • Fragment: pchar / "/" / "?"

Acceptance Criteria

  • Each component type encodes only necessary characters
  • Tests for each component type
  • Documentation with examples

Files

  • src/uri.zig:755