From 83225aba6ee8a66c903510edc6c06658f033769e Mon Sep 17 00:00:00 2001 From: Manuel Roth Date: Tue, 31 Jan 2023 10:52:59 +0100 Subject: [PATCH] Add documentation for getUrlObject function Co-authored-by: Vinayak Kulkarni <19776877+vinayakkulkarni@users.noreply.github.com> --- src/utils.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/utils.js b/src/utils.js index 152bd67..bf59b7e 100644 --- a/src/utils.js +++ b/src/utils.js @@ -6,11 +6,15 @@ import fs from 'node:fs'; import clone from 'clone'; import glyphCompose from '@mapbox/glyph-pbf-composite'; +/** +* Generate new URL object +* @params {object} req - Express request +* @returns {URL} object +**/ const getUrlObject = (req) => { const urlObject = new URL(`${req.protocol}://${req.headers.host}/`); // support overriding hostname by sending X-Forwarded-Host http header urlObject.hostname = req.hostname; - return urlObject; };