{"id":17500627,"url":"https://github.com/therealsamf/fastify-url","last_synced_at":"2026-01-20T03:31:50.959Z","repository":{"id":40790630,"uuid":"179898555","full_name":"therealsamf/fastify-url","owner":"therealsamf","description":"A plugin to provide access to a URL object","archived":false,"fork":false,"pushed_at":"2022-12-03T04:59:41.000Z","size":1669,"stargazers_count":0,"open_issues_count":23,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-13T02:16:45.633Z","etag":null,"topics":["fastify","url"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/therealsamf.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-04-06T23:42:34.000Z","updated_at":"2020-03-04T00:10:30.000Z","dependencies_parsed_at":"2023-01-23T04:16:12.650Z","dependency_job_id":null,"html_url":"https://github.com/therealsamf/fastify-url","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/therealsamf%2Ffastify-url","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/therealsamf%2Ffastify-url/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/therealsamf%2Ffastify-url/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/therealsamf%2Ffastify-url/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/therealsamf","download_url":"https://codeload.github.com/therealsamf/fastify-url/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247543598,"owners_count":20955865,"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","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":["fastify","url"],"created_at":"2024-10-19T18:42:12.509Z","updated_at":"2026-01-20T03:31:50.929Z","avatar_url":"https://github.com/therealsamf.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"fastify-url\n===========\n\n[![NPM](https://img.shields.io/npm/v/fastify-url.svg)](https://www.npmjs.com/package/fastify-url)\n[![Build Status](https://travis-ci.org/therealsamf/fastify-url.svg?branch=master)](https://travis-ci.org/therealsamf/fastify-url)\n[![codecov.io Code Coverage](https://img.shields.io/codecov/c/github/therealsamf/fastify-url.svg?maxAge=2592000)](https://codecov.io/github/therealsamf/fastify-url?branch=master) [![Greenkeeper badge](https://badges.greenkeeper.io/therealsamf/fastify-url.svg)](https://greenkeeper.io/)\n\n\n\nA plugin for [fastify](https://www.fastify.io/) for accessing an incoming [request](https://www.fastify.io/docs/latest/Request/)'s URL data.\n\n`fastify-url` is inspired by [`fastify-url-data`](https://github.com/fastify/fastify-url-data) and is just a thin wrapper around Node's [URL](https://nodejs.org/api/url.html#url_class_url) object.\n\n## Usage\n\n```javascript\nconst fastify = require('fastify')();\n\nfastify.register(require('fastify-url').default);\n\nfastify.get('/*', (req, reply) =\u003e {\n  const url = req.url();\n\n  req.log.info(url.host);          // 'sub.example.com:8080'\n  req.log.info(url.hostname);      // 'sub.example.com'\n  req.log.info(url.href);          // 'http://user:pass@sub.example.com:8080/p/a/t/h?query=string'\n  req.log.info(url.origin);        // 'http://sub.example.com:8080'\n  req.log.info(url.password);      // 'pass'\n  req.log.info(url.pathname);      // '/p/a/t/h'\n  req.log.info(url.port);          // '8080'\n  req.log.info(url.protocol);      // 'http:'\n  req.log.info(url.search);        // '?query=string'\n  req.log.info(url.username);      // 'user'\n\n  // if you just need single data:\n  req.log.info(req.url('pathname')); // '/p/a/t/h'\n\n  reply.send();\n});\n\n// GET: 'http://user:pass@sub.example.com:8080/p/a/t/h?query=string'\n```\n\n## Options\n\n### protocol\n\nType: `string`\nDefault: `http`\n\nThis property allows you to change the protocol the incoming request's URL object will absorb. This is used because it's difficult to find the protocol the request was received from within the request handler.\n\n## `fastify-url` vs `fastify-url-data`\n\nThe difference between these two plugins is `fastify-url` uses the native NodeJS [URL](https://nodejs.org/api/url.html#url_class_url) class and `fastify-url-data` uses [`uri-js`](https://github.com/garycourt/uri-js). These implementations provide some of the same features but have different data members. Depending on your requirements you may need one or the other, but using both is redundant.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftherealsamf%2Ffastify-url","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftherealsamf%2Ffastify-url","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftherealsamf%2Ffastify-url/lists"}