UNPKG

@uppy/utils

Version:

Shared utility functions for Uppy Core and plugins maintained by the Uppy team.

8 lines (7 loc) 288 B
export default function getSocketHost(url) { // 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}`; }