🚀 Big News:Socket Has Acquired Secure Annex.Learn More →
Socket
Book a DemoSign in
Socket

uses-proxy

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

uses-proxy

Check if a url shall be proxied through a http(s) proxy

latest
Source
npmnpm
Version
1.1.0
Version published
Maintainers
1
Created
Source

uses-proxy

Check if a url shall be proxied through a http(s) proxy

Implements the recommendations from https://about.gitlab.com/blog/2021/01/27/we-need-to-talk-no-proxy/

Detects and uses http(s)_proxy and no_proxy environment variables.

  • Environment variables lowercase precedence. no_proxy comes before NO_PROXY
  • Matches suffixes
  • Strips leading .
  • * matches all hosts
  • No support for regexes.
  • Supports CIDR Blocks
  • Does not match loopback IPs

usage

npm i uses-proxy
import { usesProxy, shouldProxy } from 'uses-proxy'
const {
  proxyUri, // proxy uri from https_proxy, http_proxy, ...
  protocol, // used protocol of proxy
  noProxy  // no_proxy env var content
} = usesProxy()

const matcher = shouldProxy({
  proxyUri,
  noProxy: noProxy || 'localhost, tempuri.org'
})

matcher('localhost') // >> false
matcher('test.com') // >> true
matcher('test.tempuri.org') // >> false
matcher('tempuri.org') // >> false

license

MIT licensed

Keywords

proxy

FAQs

Package last updated on 16 Jan 2025

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