diff options
author | Danny Qiu <dqiu55@gmail.com> | 2020-05-28 10:40:23 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-28 19:40:23 +0200 |
commit | 6999476b9eb71880e16b413f27a7df5bf458cd47 (patch) | |
tree | bfa71606485bf4faf9735909a09078429e168000 /src/helpers/userAgent-helpers.js | |
parent | New Crowdin translations (#745) (diff) | |
download | ferdium-app-6999476b9eb71880e16b413f27a7df5bf458cd47.tar.gz ferdium-app-6999476b9eb71880e16b413f27a7df5bf458cd47.tar.zst ferdium-app-6999476b9eb71880e16b413f27a7df5bf458cd47.zip |
Update global user agent to conform with spec (#779)
The default user agent string places Electron/8.2.3 inside parenthesis, which is defined as a comment according to https://tools.ietf.org/html/rfc7231#section-5.5.3. However, Electron should instead be specified as a product and formatted with whitespace instead of parenthesis.
Diffstat (limited to 'src/helpers/userAgent-helpers.js')
-rw-r--r-- | src/helpers/userAgent-helpers.js | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/helpers/userAgent-helpers.js b/src/helpers/userAgent-helpers.js index 15edc1054..7b994c7d4 100644 --- a/src/helpers/userAgent-helpers.js +++ b/src/helpers/userAgent-helpers.js | |||
@@ -9,7 +9,6 @@ const ferdiVersion = remote && remote.app ? remote.app.getVersion() : app.getVer | |||
9 | 9 | ||
10 | function macOS() { | 10 | function macOS() { |
11 | const version = macosVersion(); | 11 | const version = macosVersion(); |
12 | |||
13 | return `Macintosh; Intel Mac OS X ${version.replace(/\./g, '_')}`; | 12 | return `Macintosh; Intel Mac OS X ${version.replace(/\./g, '_')}`; |
14 | } | 13 | } |
15 | 14 | ||
@@ -20,7 +19,7 @@ function windows() { | |||
20 | } | 19 | } |
21 | 20 | ||
22 | function linux() { | 21 | function linux() { |
23 | return 'X11; Ubuntu; Linux x86_64'; | 22 | return 'X11; Linux x86_64'; |
24 | } | 23 | } |
25 | 24 | ||
26 | export default function userAgent(removeChromeVersion = false) { | 25 | export default function userAgent(removeChromeVersion = false) { |
@@ -34,12 +33,17 @@ export default function userAgent(removeChromeVersion = false) { | |||
34 | platformString = linux(); | 33 | platformString = linux(); |
35 | } | 34 | } |
36 | 35 | ||
36 | let chromeVersion = 'Chrome'; | ||
37 | if (!removeChromeVersion) { | ||
38 | chromeVersion = `Chrome/${process.versions.chrome}`; | ||
39 | } | ||
40 | |||
37 | let applicationString = ''; | 41 | let applicationString = ''; |
38 | if (!removeChromeVersion) { | 42 | if (!removeChromeVersion) { |
39 | applicationString = ` Ferdi/${ferdiVersion} (Electron ${process.versions.electron})`; | 43 | applicationString = ` Ferdi/${ferdiVersion} Electron/${process.versions.electron}`; |
40 | } | 44 | } |
41 | 45 | ||
42 | // TODO: Update AppleWebKit and Safari version after electron update | 46 | // Chrome is pinned to WebKit 537.36, the latest version before hard forking to Blink. |
43 | return `Mozilla/5.0 (${platformString}) AppleWebKit/537.36 (KHTML, like Gecko) Chrome${!removeChromeVersion ? `/${process.versions.chrome}` : ''} Safari/537.36${applicationString}`; | 47 | return `Mozilla/5.0 (${platformString}) AppleWebKit/537.36 (KHTML, like Gecko) ${chromeVersion} Safari/537.36${applicationString}`; |
44 | // Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) old-airport-include/1.0.0 Chrome Electron/7.1.7 Safari/537.36 | 48 | // Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.163 Safari/537.36 Ferdi/5.5.1-nightly.13 Electron/8.2.3 |
45 | } | 49 | } |