Files
socket.io/lib/xmlhttprequest.ts
Damien Arrachequesne df32277c3f refactor: import single-file 3rd party modules
This commit allows to:

- provide an ESM version of those modules ([1])
- reduce the attack surface in case of supply chain attacks
- reduce the size of the bundle with tree-shaking

As a downside, we won't receive security updates for those modules
anymore.

[1]: https://github.com/socketio/socket.io-client/issues/1536
2022-04-13 08:31:02 +02:00

24 lines
541 B
TypeScript

// browser shim for xmlhttprequest module
import { hasCORS } from "./contrib/has-cors.js";
import globalThis from "./globalThis.js";
export default function(opts) {
const xdomain = opts.xdomain;
// XMLHttpRequest can be disabled on IE
try {
if ("undefined" !== typeof XMLHttpRequest && (!xdomain || hasCORS)) {
return new XMLHttpRequest();
}
} catch (e) {}
if (!xdomain) {
try {
return new globalThis[["Active"].concat("Object").join("X")](
"Microsoft.XMLHTTP"
);
} catch (e) {}
}
}