diff --git a/plugin.js b/plugin.js index fec8923..5e6a54b 100644 --- a/plugin.js +++ b/plugin.js @@ -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 })