Skip to content

Commit

Permalink
Merge pull request #288 from dklimpel/proxy_support
Browse files Browse the repository at this point in the history
Add support to load md files via proxy
  • Loading branch information
tcort authored Mar 10, 2024
2 parents 1a5a675 + f672e40 commit 0280670
Show file tree
Hide file tree
Showing 3 changed files with 776 additions and 36 deletions.
7 changes: 5 additions & 2 deletions markdown-link-check
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const path = require('path');
const pkg = require('./package.json');
const program = require('commander');
const url = require('url');
const { ProxyAgent } = require('proxy-agent');

class Input {
constructor(filenameForOutput, stream, opts) {
Expand Down Expand Up @@ -62,7 +63,9 @@ function getInputs() {
filenameForOutput = filenameOrUrl;
let baseUrl = '';
if (/https?:/.test(filenameOrUrl)) {
stream = needle.get(filenameOrUrl);
stream = needle.get(
filenameOrUrl, { agent: new ProxyAgent(), use_proxy_from_env_var: false }
);
stream.on('error', onError);
stream.on('response', onResponse);
try { // extract baseUrl from supplied URL
Expand Down Expand Up @@ -100,7 +103,7 @@ function getInputs() {
if (config) {
input.opts.config = config.trim();
}

if (program.projectBaseUrl) {
input.opts.projectBaseUrl = `file://${program.projectBaseUrl}`;
} else {
Expand Down
Loading

0 comments on commit 0280670

Please sign in to comment.