🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

absolute-url

Package Overview
Dependencies
Maintainers
0
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

absolute-url

Get the absolute URL of an Express request

2.1.0
latest
Source
npm
Version published
Maintainers
0
Created
Source

absolute-url

build status npm version

Get the absolute URL of an Express request object.

Install

npm install --save absolute-url

Usage

The library offers two ways to use the functionality:

Function

The default export is a function that can be called with the Express request object as a parameter. It returns the absolute URL as a URL object.

import absoluteUrl from 'absolute-url'

app.use((req, res, next) => {
  console.log(absoluteUrl(req))

  next()
})

See examples/function.js for a full working example.

Middleware

The package also exports a middleware factory function. It can be used to attach a .absoluteUrl method to the Express request object. The method returns the absolute URL as a URL object.

import { middleware } from 'absolute-url'

app.use(middleware())

app.use((req, res, next) => {
  console.log(req.absoluteUrl())

  next()
})

See examples/middleware.js for a full working example.

Keywords

absolute

FAQs

Package last updated on 21 Sep 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts