Skip to content

Commit

Permalink
Switch to WHATWG URL
Browse files Browse the repository at this point in the history
Fixes Rob--W#4
  • Loading branch information
orgads committed Jun 11, 2024
1 parent 095d1c2 commit 45c4b85
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
'use strict';

var parseUrl = require('url').parse;

var DEFAULT_PORTS = {
ftp: 21,
gopher: 70,
Expand All @@ -17,12 +15,18 @@ var stringEndsWith = String.prototype.endsWith || function(s) {
};

/**
* @param {string|object} url - The URL, or the result from url.parse.
* @param {string|URL} url - The URL, as a string or as URL object.
* @return {string} The URL of the proxy that should handle the request to the
* given URL. If no proxy is set, this will be an empty string.
*/
function getProxyForUrl(url) {

Check warning on line 22 in index.js

View workflow job for this annotation

GitHub Actions / lint

Function 'getProxyForUrl' has too many statements (18). Maximum allowed is 15
var parsedUrl = typeof url === 'string' ? parseUrl(url) : url || {};
var parsedUrl = url || {};
try {
if (typeof url === 'string')

Check failure on line 25 in index.js

View workflow job for this annotation

GitHub Actions / lint

Expected { after 'if' condition
parsedUrl = new URL(url);
} catch (err) {
return '';
}
var proto = parsedUrl.protocol;
var hostname = parsedUrl.host;
var port = parsedUrl.port;
Expand Down

0 comments on commit 45c4b85

Please sign in to comment.