JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 12
  • Score
    100M100P100Q58554F
  • License MIT

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

Package Exports

  • uses-proxy
  • uses-proxy/src/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (uses-proxy) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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