Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

current-url

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

current-url

Get the current URL isomorphically.

  • 2.3.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
221
increased by6.76%
Maintainers
1
Weekly downloads
 
Created
Source

current-url

npm version

Get the current URL isomorphically.

Respects the following HTTP headers:

  • Host
  • Forwarded
  • X-Forwarded-Proto
  • X-Forwarded-Protocol
  • X-Url-Scheme
  • Front-End-Https
  • X-Forwarded-Ssl
  • X-Forwarded-Host
  • X-Forwarded-Port
  • X-Replaced-Path

Installation

yarn add current-url

Usage

In the browser call the function with no arguments:

import { currentUrl } from 'current-url';

currentUrl();

On the server call the function with a Node HTTP request object as the first argument:

import { currentUrl } from 'current-url';

currentUrl(req);

// Ignore proxies
currentUrl(req, { ignoreProxies: true });

In both cases the function returns a URL object.

Options

ignoreProxies

Type: object
Default: false

By default, the currentUrl function will take into account potential URL rewrites made by proxies, load balancers, etc. along the way (as long as these append special HTTP headers to the request). Use this option to disable that behaviour.

FAQs

Package last updated on 21 Sep 2023

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

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc