Skip to content

Commit

Permalink
bugfix: #7 User agent only contains browser (->Chrome) major version
Browse files Browse the repository at this point in the history
  • Loading branch information
manusa committed Jan 15, 2020
1 parent 2a4610c commit 707b946
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 27 deletions.
33 changes: 9 additions & 24 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
Expand Up @@ -72,7 +72,7 @@
"dictionary-tr": "^1.3.1",
"dictionary-uk": "^2.1.1",
"draggabilly": "^2.2.0",
"electron": "^7.1.6",
"electron": "^7.1.9",
"nodehun": "^3.0.1"
}
}
2 changes: 1 addition & 1 deletion src/tab-manager/__tests__/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ describe('Tab Manager module test suite', () => {
// When
const result = tabManager.getTab(1337).webContents.userAgent;
// Then
expect(result).toBe('Mozilla/5.0 (X11; Fedora; Linux x86_64) AppleWebKit/1337.36 (KHTML, like Gecko) Chrome/79.0.1337.79 Safari/537.36');
expect(result).toBe('Mozilla/5.0 (X11; Fedora; Linux x86_64) AppleWebKit/1337.36 (KHTML, like Gecko) Chrome/79 Safari/537.36');
});
describe('Event listeners', () => {
let events;
Expand Down
5 changes: 4 additions & 1 deletion src/tab-manager/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,12 @@ const handleContextMenu = browserView => async (event, params) => {
};

const cleanUserAgent = browserView => {
const currentChromeMajorVersion = /Chrome\/(?<version>[0-9]+)./g.exec(browserView.webContents.userAgent)
.groups.version;
browserView.webContents.userAgent = browserView.webContents.userAgent
.replace(/ElectronIM\/.*? /g, '')
.replace(/Electron\/.*? /g, '');
.replace(/Electron\/.*? /g, '')
.replace(/Chrome\/(\S+)/g, `Chrome/${currentChromeMajorVersion}`);
};

const addTabs = ipcSender => tabsMetadata => {
Expand Down

0 comments on commit 707b946

Please sign in to comment.