Skip to content

Commit

Permalink
fix(proxy): Improve proxy URL handling for non-standard ports
Browse files Browse the repository at this point in the history
  • Loading branch information
zardoy committed Jan 31, 2025
1 parent 8766eaa commit 81aaaab
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,10 @@ async function connect (connectOptions: ConnectOptions) {
if (connectOptions.proxy?.startsWith(':')) {
connectOptions.proxy = `${location.protocol}//${location.hostname}${connectOptions.proxy}`
}
if (connectOptions.proxy && location.port !== '80' && location.port !== '443' && !/:\d+$/.test(connectOptions.proxy)) {
const https = connectOptions.proxy.startsWith('https://') || location.protocol === 'https:'
connectOptions.proxy = `${connectOptions.proxy}:${https ? 443 : 80}`
}
const proxy = cleanConnectIp(connectOptions.proxy, undefined)
let { username } = connectOptions

Expand Down
2 changes: 1 addition & 1 deletion src/react/ServersListProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ const Inner = ({ hidden, customServersList }: { hidden?: boolean, customServersL
try {
lastRequestStart = Date.now()
if (signal.aborted) return
const response = await fetch(`https://api.mcstatus.io/v2/status/java/${server.ip}`, {
const response = await fetch(`https://api.mcstatus.io/v2/status/java/${server.ip}`, {
// signal // DONT ADD SIGNAL IT WILL CRUSH JS RUNTIME
})
const data: ServerResponse = await response.json()
Expand Down

0 comments on commit 81aaaab

Please sign in to comment.