Skip to content

Commit

Permalink
fix port
Browse files Browse the repository at this point in the history
  • Loading branch information
gurgunday committed Jul 13, 2024
1 parent 3958226 commit c8dd240
Showing 1 changed file with 3 additions and 2 deletions.
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

0 comments on commit c8dd240

Please sign in to comment.