Skip to content

Commit

Permalink
v1.2.42
Browse files Browse the repository at this point in the history
  • Loading branch information
binary-person committed Dec 9, 2022
1 parent 271317f commit ad19523
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 11 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## v1.2.42

- fix localStorage's getItem referencing parent in iframes

## v1.2.41

- handle removeStaleSessions of .get() returning undefined from corrupted session files
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rammerhead",
"version": "1.2.41",
"version": "1.2.42",
"description": "User friendly web proxy powered by testcafe-hammerhead",
"main": "src/index.js",
"scripts": {
Expand Down
17 changes: 9 additions & 8 deletions src/client/rammerhead.js
Original file line number Diff line number Diff line change
Expand Up @@ -378,12 +378,13 @@
// completely replace hammerhead's implementation as restore() and save() on every
// call is just not viable (mainly memory issues as the garbage collector is sometimes not fast enough)

const prefix = `rammerhead|storage-wrapper|${hammerhead.settings._settings.sessionId}|${
window.__get$(window, 'location').host
const getLocHost = win => win.__get$(win, 'location').host;
const prefix = win => `rammerhead|storage-wrapper|${hammerhead.settings._settings.sessionId}|${
getLocHost(win)
}|`;
const toRealStorageKey = (key = '') => prefix + key;
const fromRealStorageKey = (key = '') => {
if (!key.startsWith(prefix)) return null;
const toRealStorageKey = (key = '', win = window) => prefix(win) + key;
const fromRealStorageKey = (key = '', win = window) => {
if (!key.startsWith(prefix(win))) return null;
return key.slice(prefix.length);
};

Expand Down Expand Up @@ -461,15 +462,15 @@
return (Object.entries(this)[keyNum] || [])[0] || null;
});
rewriteFunction('getItem', function (key) {
return this.internal.nativeStorage[toRealStorageKey(key)] || null;
return this.internal.nativeStorage[toRealStorageKey(key, this.internal.ctx)] || null;
});
rewriteFunction('setItem', function (key, value) {
if (key) {
this.internal.nativeStorage[toRealStorageKey(key)] = value;
this.internal.nativeStorage[toRealStorageKey(key, this.internal.ctx)] = value;
}
});
rewriteFunction('removeItem', function (key) {
delete this.internal.nativeStorage[toRealStorageKey(key)];
delete this.internal.nativeStorage[toRealStorageKey(key, this.internal.ctx)];
});
}

Expand Down
1 change: 1 addition & 0 deletions src/server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ if (enableWorkers) {
return sessionId.split('').map((e) => e.charCodeAt());
}
};
logger.info(JSON.stringify({ port: config.port, crossPort: config.crossDomainPort, master: cluster.isMaster }));
const closeMasters = [sticky.listen(proxyServer.server1, config.port, config.bindingAddress, stickyOptions)];
if (config.crossDomainPort) {
closeMasters.push(
Expand Down

0 comments on commit ad19523

Please sign in to comment.