Skip to content
Permalink
Browse files
fix(Service): Fix issue with user agent override in service workers
  • Loading branch information
adlk committed Mar 27, 2020
1 parent 922f861 commit a8dea57b39e7b0a03695225c6e4c998120fc044e
Showing 4 changed files with 55 additions and 5 deletions.

Some generated files are not rendered by default. Learn more.

@@ -57,6 +57,7 @@
"hex-to-rgba": "1.0.2",
"jsonwebtoken": "8.5.1",
"lodash": "^4.17.4",
"macos-version": "5.2.0",
"marked": "0.6.1",
"mdi": "^1.9.33",
"mime-types": "2.1.21",
@@ -0,0 +1,35 @@

import os from 'os';
import macosVersion from 'macos-version';
import { isMac, isWindows } from '../environment';

function macOS() {
const version = macosVersion();

return `Macintosh; Intel Mac OS X ${version.replace('.', '_')}`;
}

function windows() {
const version = os.release();
const [majorVersion, minorVersion] = version.split('.');
return `Windows NT ${majorVersion}.${minorVersion}; Win64; x64`;
}

function linux() {
return 'X11; Ubuntu; Linux x86_64';
}

export default function userAgent() {
let platformString = '';

if (isMac) {
platformString = macOS();
} else if (isWindows) {
platformString = windows();
} else {
platformString = linux();
}

// TODO: Update AppleWebKit and Safari version after electron update
return `Mozilla/5.0 (${platformString}) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/${process.versions.chrome} Safari/537.36`;
}
@@ -22,6 +22,7 @@ if (isDevMode) {
app.setPath('userData', path.join(app.getPath('appData'), 'FranzDev'));
}


/* eslint-disable import/first */
import {
isMac,
@@ -43,10 +44,15 @@ import {
} from './config';
import { asarPath } from './helpers/asar-helpers';
import { isValidExternalURL } from './helpers/url-helpers';
/* eslint-enable import/first */
import userAgent from './electron/userAgent';

/* eslint-enable import/first */
const debug = require('debug')('Franz:App');

// Globally set useragent to fix user agent override in service workers
debug('Set userAgent to ', userAgent());
app.userAgentFallback = userAgent();

// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
let mainWindow;

0 comments on commit a8dea57

Please sign in to comment.