https://github.com/atomantic/is-ua-webview
📱tiny/simple npm module for detecting webview status of a user-agent
https://github.com/atomantic/is-ua-webview
Last synced: 9 months ago
JSON representation
📱tiny/simple npm module for detecting webview status of a user-agent
- Host: GitHub
- URL: https://github.com/atomantic/is-ua-webview
- Owner: atomantic
- License: isc
- Created: 2017-06-03T18:26:12.000Z (about 9 years ago)
- Default Branch: main
- Last Pushed: 2022-12-01T23:26:52.000Z (over 3 years ago)
- Last Synced: 2025-10-05T00:53:09.462Z (9 months ago)
- Language: JavaScript
- Homepage:
- Size: 41 KB
- Stars: 64
- Watchers: 3
- Forks: 7
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# is-ua-webview
A super simple webview user-agent detector
[](https://travis-ci.org/atomantic/is-ua-webview) [](https://www.npmjs.org/package/is-ua-webview)
[](https://www.npmjs.org/package/is-ua-webview)
## Installation
$ npm install is-ua-webview
## Usage
```js
const isWebview = require("is-ua-webview");
// just for testing:
const assert = require("assert");
// Facebook App embedded page load
assert(
isWebview(
"Mozilla/5.0 (Linux; Android 4.4.4; One Build/KTU84L.H4) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/33.0.0.0 Mobile Safari/537.36 [FB_IAB/FB4A;FBAV/28.0.0.20.16;]"
)
);
// Chrome/Android browser
assert(
!isWebview(
"Mozilla/5.0 (Linux; Android 4.4.4; One Build/KTU84L.H4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.135 Mobile Safari/537.36"
)
);
```
## Tests
Run tests
```bash
npm test
```
## Why
This was built for a web service that wanted to add a logging point in case the page load came from inside a webview where cookies were possibly throw away (not treated the same as a SafariViewController or native browser load). The tests are lacking completeness as this tool was only being used to discover and add detection in logs. The author of this module is no longer the owner/maintainer of the production service that used this module, so if you are interested in using it, please consider adding more tests and make a PR with tests :)