@tomphttp/bare-client
Advanced tools
Comparing version 1.1.1 to 1.1.2-beta
@@ -744,2 +744,17 @@ // The user likely has overwritten all networking functions after importing bare-client | ||
} | ||
function resolvePort(url) { | ||
if (url.port) | ||
return Number(url.port); | ||
switch (url.protocol) { | ||
case 'ws:': | ||
case 'http:': | ||
return 80; | ||
case 'wss:': | ||
case 'https:': | ||
return 443; | ||
default: | ||
// maybe blob | ||
return 0; | ||
} | ||
} | ||
class BareClient { | ||
@@ -827,3 +842,3 @@ /** | ||
requestHeaders['Sec-Websocket-Protocol'] = protocols.join(', '); | ||
return this.connect(requestHeaders, url.protocol, url.hostname, url.port, url.pathname + url.search); | ||
return this.connect(requestHeaders, url.protocol, url.hostname, resolvePort(url), url.pathname + url.search); | ||
} | ||
@@ -879,16 +894,4 @@ async fetch(url, init = {}) { | ||
for (let i = 0;; i++) { | ||
let port; | ||
if (url.port === '') { | ||
if (url.protocol === 'https:') { | ||
port = '443'; | ||
} | ||
else { | ||
port = '80'; | ||
} | ||
} | ||
else { | ||
port = url.port; | ||
} | ||
headers.host = url.host; | ||
const response = await this.request(method, headers, body, url.protocol, url.hostname, port, url.pathname + url.search, cache, signal); | ||
const response = await this.request(method, headers, body, url.protocol, url.hostname, resolvePort(url), url.pathname + url.search, cache, signal); | ||
response.finalURL = url.toString(); | ||
@@ -895,0 +898,0 @@ if (statusRedirect.includes(response.status)) { |
{ | ||
"name": "@tomphttp/bare-client", | ||
"version": "1.1.1", | ||
"version": "1.1.2-beta", | ||
"homepage": "https://github.com/tomphttp", | ||
@@ -5,0 +5,0 @@ "bugs": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
252655
2069
1