Code Monkey home page Code Monkey logo

is-ua-webview's Introduction

is-ua-webview

A super simple webview user-agent detector

Build Status

Installation

$ npm install is-ua-webview

Usage

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

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 :)

is-ua-webview's People

Contributors

atomantic avatar devyeshtandon avatar emrahyumuk avatar kotarella1110 avatar steveluscher avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

is-ua-webview's Issues

Does library Support Chrome's User Agent reductions?

Sorry about filing an issue that might be solved, but https://blog.chromium.org/2021/05/update-on-user-agent-string-reduction.html

Does this library continue to work with the reduced User Agent strings?

Here are the final strings: https://www.chromium.org/updates/ua-reduction/#sample-ua-strings-final-reduced-state

Please let me know and feel free to close if already addressed.

Do you plan to use chrome's hint system? https://developer.chrome.com/articles/user-agent-client-hints/

Doesn't work in iPhone 8 Plus, Gmail App

Doesn't work for Mozilla/5.0 (iPhone; CPU iPhone OS 12_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.0 Mobile/15E148 Safari/604.1 (iPhone 8 Plus, Gmail App)

Should return false for Chrome on Android

Unfortunately returns true for the following UA:

Mozilla/5.0 (Linux; Android 12; ingot) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.0.0 Mobile Safari/537.36

…because of this rule:

  // Android Lollipop and Above: webview will be the same as native but it will contain "wv"
  // Android KitKat to lollipop webview will put {version}.0.0.0
  'Android.*(wv|.0.0.0)',

It's accidentally matching the Chrome/106.0.0.0 section.

Missing typings

Hi,
Thank you for this package, it's useful :-)
Could you please publish a new version on npm with the typings? It seems that the published version doesn't have them.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.