jstd-web/node_modules/@uppy/utils/lib/getSocketHost.js

11 lines
318 B
JavaScript
Raw Normal View History

2025-11-25 15:23:22 +08:00
"use strict";
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}`;
}
module.exports = getSocketHost;