You've already forked AstralRinth
cont: fix(frontend): dont assume wss for panel pingtest as well (#6421)
* fix(frontend): dont assume wss for panel pingtest as well * fix(frontend): wss assumptions * chore: fix export * chore: prettier
This commit is contained in:
committed by
GitHub
parent
336050f4df
commit
486b467af2
@@ -43,6 +43,7 @@ export { XHRUploadClient } from './platform/xhr-upload-client'
|
||||
export { clearNodeAuthState, nodeAuthState, setNodeAuthState } from './state/node-auth'
|
||||
export * from './types'
|
||||
export { withJWTRetry } from './utils/jwt-retry'
|
||||
export { getNodeWebSocketUrl } from './utils/node-url'
|
||||
export {
|
||||
type ParsedSseEvent,
|
||||
type ParsedSseItem,
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
const NODE_FS_PATH_REGEX = /\/modrinth\/v\d+\/fs\/?$/
|
||||
const HTTP_SCHEME_REGEX = /^https?:\/\//i
|
||||
const WS_SCHEME_REGEX = /^wss?:\/\//i
|
||||
const HTTP_SECURE_SCHEME_REGEX = /^https:\/\//i
|
||||
const HTTP_INSECURE_SCHEME_REGEX = /^http:\/\//i
|
||||
|
||||
export function getNodeBaseUrl(url: string): string {
|
||||
const baseUrl = url.replace(NODE_FS_PATH_REGEX, '')
|
||||
@@ -8,5 +10,9 @@ export function getNodeBaseUrl(url: string): string {
|
||||
}
|
||||
|
||||
export function getNodeWebSocketUrl(url: string): string {
|
||||
return WS_SCHEME_REGEX.test(url) ? url : `wss://${url}`
|
||||
if (WS_SCHEME_REGEX.test(url)) return url
|
||||
if (HTTP_SECURE_SCHEME_REGEX.test(url)) return url.replace(HTTP_SECURE_SCHEME_REGEX, 'wss://')
|
||||
if (HTTP_INSECURE_SCHEME_REGEX.test(url)) return url.replace(HTTP_INSECURE_SCHEME_REGEX, 'ws://')
|
||||
|
||||
return `wss://${url}`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user