mirror of
https://github.com/transloadit/uppy.git
synced 2026-07-26 03:35:19 +00:00
8 lines
286 B
JavaScript
8 lines
286 B
JavaScript
module.exports = function getSocketHost (url) {
|
|
// 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}`
|
|
}
|