feat(frontend): don't assume secure protocol for kyros websocket/fs (#6420)

* feat(frontend): don't assume https as websocket/fs protocol

* fix(frontend): actually do the same for websocket

* fix(frontend): don't strip ws path
This commit is contained in:
François-Xavier Talbot
2026-06-16 21:39:38 +00:00
committed by GitHub
parent 8591bc8ebc
commit 5ed322d281
4 changed files with 18 additions and 3 deletions
+12
View File
@@ -0,0 +1,12 @@
const NODE_FS_PATH_REGEX = /\/modrinth\/v\d+\/fs\/?$/
const HTTP_SCHEME_REGEX = /^https?:\/\//i
const WS_SCHEME_REGEX = /^wss?:\/\//i
export function getNodeBaseUrl(url: string): string {
const baseUrl = url.replace(NODE_FS_PATH_REGEX, '')
return HTTP_SCHEME_REGEX.test(baseUrl) ? baseUrl : `https://${baseUrl}`
}
export function getNodeWebSocketUrl(url: string): string {
return WS_SCHEME_REGEX.test(url) ? url : `wss://${url}`
}