Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('should passes when used properly', () => {
Constants.getWebViewUserAgentAsync().then(ua => {
if (ua !== null) {
(ua: string);
// $ExpectError: check any
(ua: number);
} else {
(ua: null);
}
});
});
});
private async updateWebViewUserAgent() {
const userAgent = await Constants.getWebViewUserAgentAsync();
this.setState({
webViewUserAgent: userAgent
});
}
}
Constants.getWebViewUserAgentAsync()} />
export async function hm(url, screen) {
if (DEV) {
log(`[hm] ${url} ${screen}`)
return
}
try {
if (!ua) ua = await Constants.getWebViewUserAgentAsync()
let u = String(url).indexOf('http') === -1 ? `${HOST}/${url}` : url
u += `${u.includes('?') ? '&' : '?'}v=${VERSION_GITHUB_RELEASE}`
u += `${require('../stores/theme').default.isDark ? '&dark=1' : ''}`
u += `${screen ? `&s=${screen}` : ''}`
const request = new XMLHttpRequest()
request.open(
'GET',
`https://hm.baidu.com/hm.gif?${urlStringify({
rnd: randomn(10),
si: IOS
? '8f9e60c6b1e92f2eddfd2ef6474a0d11'
: '2dcb6644739ae08a1748c45fb4cea087',
v: '1.2.51',
api: '4_0',
return new Promise((resolve) => {
if (options.userAgent) {
webViewUserAgent = options.userAgent;
return resolve(options.userAgent);
}
if (webViewUserAgent) return resolve(webViewUserAgent);
Constants.getWebViewUserAgentAsync()
.then(userAgent => {
webViewUserAgent = userAgent;
resolve(userAgent);
})
.catch(() => resolve('unknown user agent'))
});
}