MCPcopy Create free account
hub / github.com/deta/surf / normalizeElectronUserAgent

Function normalizeElectronUserAgent

app/src/main/utils.ts:79–108  ·  view source on GitHub ↗
(current: string, isGoogleAccounts: boolean)

Source from the content-addressed store, hash-verified

77}
78
79export const normalizeElectronUserAgent = (current: string, isGoogleAccounts: boolean): string => {
80 // For Google sign-in pages, we keep the Surf version at the end of the User-Agent
81 // to avoid "secure browser" warnings. For everything else, we strip out both
82 // Electron and Surf versions.
83 const surfVersion =
84 current
85 .split(' ')
86 .find((part) => part.startsWith('Surf/'))
87 ?.replace('Surf/', '') || ''
88
89 let result = current
90 .split(' ')
91 .filter((part) => !part.startsWith('Electron/') && !part.startsWith('Surf/'))
92 .join(' ')
93 .replace(
94 process.versions.chrome || '',
95 process.versions?.chrome
96 ? process.versions.chrome
97 .split('.')
98 .map((v, idx) => (idx === 0 ? v : '0'))
99 .join('.')
100 : ''
101 )
102
103 if (isGoogleAccounts && surfVersion) {
104 result += ` Surf/${surfVersion}`
105 }
106
107 return result
108}
109
110export const firefoxUA = (() => {
111 const platformMap = {

Callers 1

createWindowFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected