Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge next into master #147

Merged
merged 5 commits into from
Jul 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ on:

jobs:
test:
uses: fastify/workflows/.github/workflows/plugins-ci.yml@v3
uses: fastify/workflows/.github/workflows/plugins-ci.yml@v4.0.0
with:
license-check: true
lint: true
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ lib-cov
coverage
*.lcov

# .tap output
.tap

# nyc test coverage
.nyc_output

Expand Down
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,19 @@
},
"homepage": "https://github.com/fastify/fastify-url-data#readme",
"devDependencies": {
"@fastify/pre-commit": "^2.0.2",
"@types/node": "^20.1.0",
"fastify": "^4.0.0-rc.2",
"@fastify/pre-commit": "^2.1.0",
"@types/node": "^20.11.6",
"fastify": "^5.0.0-alpha.3",
"h2url": "^0.2.0",
"semver": "^7.3.2",
"semver": "^7.5.4",
"snazzy": "^9.0.0",
"standard": "^17.0.0",
"tap": "^16.0.0",
"standard": "^17.1.0",
"tap": "^18.6.1",
"tsd": "~0.31.0"
},
"dependencies": {
"fast-uri": "^3.0.0",
"fastify-plugin": "^4.0.0"
"fastify-plugin": "^4.5.1"
},
"publishConfig": {
"access": "public"
Expand Down
5 changes: 3 additions & 2 deletions plugin.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
'use strict'

const fp = require('fastify-plugin')
const fastUri = require('fast-uri')
const { parse } = require('fast-uri')

function fastifyUrlData (fastify, options, next) {
fastify.decorateRequest('urlData', function (key) {
const scheme = this.headers[':scheme'] ? this.headers[':scheme'] : this.protocol
const host = this.hostname
const port = this.port
const path = this.headers[':path'] || this.raw.url
const urlData = fastUri.parse(scheme + '://' + host + path)
const urlData = parse(`${scheme}://${host}:${port}${path}`)
if (key) return urlData[key]
return urlData
})
Expand Down
Loading