django-vue3-admin-web/node_modules/@uppy/utils/lib/getSocketHost.js
2025-10-20 21:21:14 +08:00

11 lines
318 B
JavaScript

"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;