Add documentation for getUrlObject function
Co-authored-by: Vinayak Kulkarni <19776877+vinayakkulkarni@users.noreply.github.com>
This commit is contained in:
parent
49f7b99321
commit
83225aba6e
1 changed files with 5 additions and 1 deletions
|
|
@ -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;
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue