UNPKG

@uppy/utils

Version:

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

9 lines (7 loc) 301 B
export default function getSocketHost(url: string): string { // get the host domain const regex = /^(?:https?:\/\/|\/\/)?(?:[^@\n]+@)?(?:www\.)?([^\n]+)/i const host = regex.exec(url)?.[1] const socketProtocol = /^http:\/\//i.test(url) ? 'ws' : 'wss' return `${socketProtocol}://${host}` }