mirror of
https://github.com/MercuryWorkshop/scramjet.git
synced 2025-05-15 07:20:02 -04:00
location proxy still buggy
This commit is contained in:
parent
077302aada
commit
8217897d1e
1 changed files with 6 additions and 4 deletions
|
@ -14,6 +14,8 @@ export function createLocationProxy(
|
||||||
Object.setPrototypeOf(fakeLocation, Location.prototype);
|
Object.setPrototypeOf(fakeLocation, Location.prototype);
|
||||||
fakeLocation.constructor = Location;
|
fakeLocation.constructor = Location;
|
||||||
|
|
||||||
|
// for some reason it's on the object for Location and on the prototype for WorkerLocation??
|
||||||
|
const descriptorSource = iswindow ? self.location : Location.prototype;
|
||||||
const urlprops = [
|
const urlprops = [
|
||||||
"protocol",
|
"protocol",
|
||||||
"hash",
|
"hash",
|
||||||
|
@ -26,7 +28,7 @@ export function createLocationProxy(
|
||||||
"search",
|
"search",
|
||||||
];
|
];
|
||||||
for (const prop of urlprops) {
|
for (const prop of urlprops) {
|
||||||
const native = nativeGetOwnPropertyDescriptor(self.location, prop);
|
const native = nativeGetOwnPropertyDescriptor(descriptorSource, prop);
|
||||||
if (!native) continue;
|
if (!native) continue;
|
||||||
|
|
||||||
const desc = {
|
const desc = {
|
||||||
|
@ -75,20 +77,20 @@ export function createLocationProxy(
|
||||||
fakeLocation.assign = new Proxy(self.location.assign, {
|
fakeLocation.assign = new Proxy(self.location.assign, {
|
||||||
apply(target, thisArg, args) {
|
apply(target, thisArg, args) {
|
||||||
args[0] = encodeUrl(args[0]);
|
args[0] = encodeUrl(args[0]);
|
||||||
Reflect.apply(target, thisArg, args);
|
Reflect.apply(target, self.location, args);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
if (self.location.reload)
|
if (self.location.reload)
|
||||||
fakeLocation.reload = new Proxy(self.location.reload, {
|
fakeLocation.reload = new Proxy(self.location.reload, {
|
||||||
apply(target, thisArg, args) {
|
apply(target, thisArg, args) {
|
||||||
Reflect.apply(target, thisArg, args);
|
Reflect.apply(target, self.location, args);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
if (self.location.replace)
|
if (self.location.replace)
|
||||||
fakeLocation.replace = new Proxy(self.location.replace, {
|
fakeLocation.replace = new Proxy(self.location.replace, {
|
||||||
apply(target, thisArg, args) {
|
apply(target, thisArg, args) {
|
||||||
args[0] = encodeUrl(args[0]);
|
args[0] = encodeUrl(args[0]);
|
||||||
Reflect.apply(target, thisArg, args);
|
Reflect.apply(target, self.location, args);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue