mirror of
https://github.com/MercuryWorkshop/scramjet.git
synced 2025-05-15 23:30:00 -04:00
23 lines
629 B
TypeScript
23 lines
629 B
TypeScript
import { encodeUrl, rewriteHeaders } from "../shared"
|
|
|
|
XMLHttpRequest.prototype.open = new Proxy(XMLHttpRequest.prototype.open, {
|
|
apply(target, thisArg, argArray) {
|
|
if (argArray[1]) argArray[1] = encodeUrl(argArray[1])
|
|
|
|
return Reflect.apply(target, thisArg, argArray)
|
|
},
|
|
})
|
|
|
|
XMLHttpRequest.prototype.setRequestHeader = new Proxy(
|
|
XMLHttpRequest.prototype.setRequestHeader,
|
|
{
|
|
apply(target, thisArg, argArray) {
|
|
let headerObject = Object.fromEntries([argArray])
|
|
headerObject = rewriteHeaders(headerObject)
|
|
|
|
argArray = Object.entries(headerObject)[0]
|
|
|
|
return Reflect.apply(target, thisArg, argArray)
|
|
},
|
|
}
|
|
)
|