{"id":13705743,"url":"https://github.com/petere/pguri","last_synced_at":"2025-10-09T03:07:54.458Z","repository":{"id":27472570,"uuid":"30951894","full_name":"petere/pguri","owner":"petere","description":"uri type for PostgreSQL","archived":false,"fork":false,"pushed_at":"2025-03-26T10:54:02.000Z","size":37,"stargazers_count":320,"open_issues_count":10,"forks_count":20,"subscribers_count":13,"default_branch":"master","last_synced_at":"2025-10-09T03:05:00.360Z","etag":null,"topics":["postgresql","postgresql-extension","uri","url"],"latest_commit_sha":null,"homepage":"https://twitter.com/pvh/status/567395527357001728","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/petere.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2015-02-18T04:21:50.000Z","updated_at":"2025-10-06T09:16:25.000Z","dependencies_parsed_at":"2024-01-14T20:17:06.651Z","dependency_job_id":"1eb2b179-ac1c-4313-bfa0-b3cfcfb32dc1","html_url":"https://github.com/petere/pguri","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/petere/pguri","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/petere%2Fpguri","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/petere%2Fpguri/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/petere%2Fpguri/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/petere%2Fpguri/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/petere","download_url":"https://codeload.github.com/petere/pguri/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/petere%2Fpguri/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279000775,"owners_count":26082911,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-09T02:00:07.460Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["postgresql","postgresql-extension","uri","url"],"created_at":"2024-08-02T22:00:47.169Z","updated_at":"2025-10-09T03:07:54.443Z","avatar_url":"https://github.com/petere.png","language":"C","funding_links":[],"categories":["C"],"sub_categories":[],"readme":"`uri` type for PostgreSQL\n=========================\n\nhttps://twitter.com/pvh/status/567395527357001728\n\nThis is an extension for PostgreSQL that provides a `uri` data type.\nAdvantages over using plain `text` for storing URIs include:\n\n- URI syntax checking\n- functions for extracting URI components\n- human-friendly sorting\n\nThe actual URI parsing is provided by the\n[uriparser](http://uriparser.sourceforge.net/) library, which supports\nURI syntax as per [RFC 3986](http://tools.ietf.org/html/rfc3986).\n\nNote that this might not be the right data type to use if you want to\nstore user-provided URI data, such as HTTP referrers, since they might\ncontain arbitrary junk.\n\nInstallation\n------------\n\nYou need to have the above-mentioned `uriparser` library installed.\nIt is included in many operating system distributions and package\nmanagement systems.  `pkg-config` will be used to find it.  I\nrecommend at least version 0.8.0.  Older versions will also work, but\nthey apparently contain some bugs and might fail to correctly accept\nor reject URI syntax corner cases.  This is mainly a problem if your\napplication needs to be robust against junk input.\n\nTo build and install this module:\n\n    make\n    make install\n\nor selecting a specific PostgreSQL installation:\n\n    make PG_CONFIG=/some/where/bin/pg_config\n    make PG_CONFIG=/some/where/bin/pg_config install\n\nAnd finally inside the database:\n\n    CREATE EXTENSION uri;\n\nUsing\n-----\n\nThis module provides a data type `uri` that you can use like a normal\ntype.  For example:\n\n```sql\nCREATE TABLE links (\n    id int PRIMARY KEY,\n    link uri\n);\n\nINSERT INTO links VALUES (1, 'https://github.com/petere/pguri');\n```\n\nA number of functions are provided to extract parts of a URI:\n\n- `uri_scheme(uri) returns text`\n\n    Extracts the scheme of a URI, for example `http` or `ftp` or\n    `mailto`.\n\n- `uri_userinfo(uri) returns text`\n\n    Extracts the user info part of a URI.  This is normally a user\n    name, but could also be of the form `username:password`.  If the\n    URI does not contain a user info part, then this will return null.\n\n- `uri_host(uri) returns text`\n\n    Extracts the host of a URI, for example `www.example.com` or\n    `192.168.0.1`.  (For IPv6 addresses, the brackets are not included\n    here.)  If there is no host, the return value is null.\n\n- `uri_host_inet(uri) returns inet`\n\n    If the host is a raw IP address, then this will return it as an\n    `inet` datum.  Otherwise (not an IP address or no host at all),\n    the return value is null.\n\n- `uri_port(uri) returns integer`\n\n    Extracts the port of a URI as an integer, for example `5432`.  If\n    no port is specified, the return value is null.\n\n- `uri_path(uri) returns text`\n\n    Extracts the path component of a URI.  Logically, a URI always\n    contains a path.  The return value can be an empty string but\n    never null.\n\n- `uri_path_array(uri) returns text[]`\n\n    Returns the path component of a URI as an array, with the path\n    split at the slash characters.  This is probably not as useful as\n    the `uri_path` function, but it is provided here because the\n    `uriparser` library exposes it.\n\n- `uri_query(uri) returns text`\n\n    Extracts the query part of a URI (roughly speaking, everything\n    after the `?`).  If there is no query part, returns null.\n\n- `uri_fragment(uri) returns text`\n\n    Extracts the fragment part of a URI (roughly speaking, everything\n    after the `#`).  If there is no fragment part, returns null.\n\nOther functions:\n\n- `uri_normalize(uri) returns uri`\n\n    Performs syntax-based normalization of the URI.  This includes\n    case normalization, percent-encoding normalization, and removing\n    redundant `.` and `..` path segments.  See\n    [RFC 3986 section 6.2.2](http://tools.ietf.org/html/rfc3986#section-6.2.2)\n    for the full details.\n\n    Note that this module (and similar modules in other programming\n    languages) compares URIs for equality in their original form,\n    without normalization.  If you want to consider distinct URIs\n    without regard for mostly irrelevant syntax differences, pass them\n    through this function.\n\n- `uri_escape(text, space_to_plus boolean DEFAULT false, normalize_breaks boolean DEFAULT false) returns text`\n\n    Percent-encodes all reserved characters from the text.  This can\n    be useful for constructing URIs from strings.\n\n    If `space_to_plus` is true, then spaces are replaced by plus\n    signs.  If `normalize_breaks` is true, then line breaks are\n    converted to CR LF pairs (and subsequently percent-encoded).  Note\n    that these two conversions come from the HTML standard for\n    encoding form data but are not part of the specification for URIs.\n\n- `uri_unescape(text, plus_to_space boolean DEFAULT false, break_conversion boolean DEFAULT false) returns text`\n\n    Decodes all percent-encodings in the text.\n\n    If `plus_to_space` is true, then plus signs are converted to\n    spaces.  If `break_conversion` is true, then CR LF pairs are\n    converted to simple newlines (`\\n`).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpetere%2Fpguri","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpetere%2Fpguri","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpetere%2Fpguri/lists"}