should-proxy - Checks if a url should be proxied


SUBMITTED BY: cramer

DATE: Sept. 10, 2015, 3:34 p.m.

UPDATED: Sept. 10, 2015, 3:34 p.m.

FORMAT: HTML

SIZE: 894 Bytes

HITS: 1187

  1. #should-proxy
  2. should-proxy uses a no_proxy list formatted like so localhost,127.0.0.0/8,10.0.0.0/8,192.168.0.0/16,172.16.0.0/12,.internal.com To determine if a url should be proxied or not.
  3. should-proxy is a function that takes a url as well as options. If no options are provided should-proxy uses the environment variable no_proxy
  4. Usage
  5. var shouldProxy = require('should-proxy');
  6. var result = shouldProxy("http://something.google.com/", {
  7. no_proxy: "google.com"
  8. });
  9. // Should be false, because google.com is on the no_proxy list provided
  10. console.log("http://something.google.com/", result);
  11. result = shouldProxy("http://localhost/", {
  12. no_proxy: ""
  13. });
  14. // Should be true, because localhost is not the no_proxy list provided
  15. console.log("http://localhost/", result);
  16. // Omitting the options object will cause should-proxy
  17. // to use process.env["no_proxy"]

comments powered by Disqus