Socket
Socket
Sign inDemoInstall

absolute-url

Package Overview
Dependencies
0
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    absolute-url

Get the absolute URL of an Express request


Version published
Weekly downloads
260
decreased by-67.25%
Maintainers
1
Created
Weekly downloads
 

Readme

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

FAQs

Last updated on 13 Oct 2023

Did you know?

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc