mirror of
https://github.com/transloadit/uppy.git
synced 2026-07-18 00:55:35 +00:00
8 lines
291 B
TypeScript
8 lines
291 B
TypeScript
export default function getSocketHost(url: string): string {
|
|
// get the host domain
|
|
const regex = /^(?:https?:\/\/|\/\/)?(?:[^@\n]+@)?([^\n]+)/i
|
|
const host = regex.exec(url)?.[1]
|
|
const socketProtocol = /^http:\/\//i.test(url) ? 'ws' : 'wss'
|
|
|
|
return `${socketProtocol}://${host}`
|
|
}
|