UNPKG

@uppy/utils

Version:

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

8 lines 341 B
export default function getSocketHost(url) { var _regex$exec; // get the host domain const regex = /^(?:https?:\/\/|\/\/)?(?:[^@\n]+@)?([^\n]+)/i; const host = (_regex$exec = regex.exec(url)) == null ? void 0 : _regex$exec[1]; const socketProtocol = /^http:\/\//i.test(url) ? 'ws' : 'wss'; return `${socketProtocol}://${host}`; }