url
url · SQL and PL/pgSQL types and helper functions for URL parsing, encoding, decoding, and query-string key/value handling.
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 100293 | url | url | 1.0 | TYPE | BSD-3-Clause | SQL |
Usage
Sources:
url (the pg_url project) is a pure SQL/PL/pgSQL library for parsing URLs, percent-encoding values, and working with query strings as structured PostgreSQL values. It performs no HTTP request and does not resolve or validate remote hosts.
Core Workflow
The composite url type has scheme, authority, domain, port, path, querystring, and fragment fields. Text can be converted with url(text) or a cast and reconstructed by casting back to text. qskv stores an array of kventry values: -> returns the first value for a key, while ->> returns all matching values as text[]. unnest(qskv) emits key/value rows.
Parsing Boundaries
The implementation is a regular-expression parser written for PostgreSQL 9.4-era syntax, not a complete standards or security validator. Test internationalized domain names, IPv6 literals, unusual user information, invalid percent escapes, duplicate/empty query keys, + handling, and round trips before adopting it. Parsed domain or path values are still untrusted input; applications must separately enforce allowed schemes and destinations to prevent SSRF or open redirects. No network preload, restart, or server filesystem access is required.