Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

detect-mobile-browser

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

detect-mobile-browser - npm Package Compare versions

Comparing version 4.0.0 to 5.0.0

2

bower.json
{
"name": "browser-detector",
"version": "1.0.0",
"version": "4.0.1",
"homepage": "https://github.com/smali-kazmi/detect-mobile-browser",

@@ -5,0 +5,0 @@ "authors": [

{
"name": "detect-mobile-browser",
"version": "4.0.0",
"version": "5.0.0",
"description": "It is a very simple & small javascript plugin to detect all major modern mobile browsers.",

@@ -5,0 +5,0 @@ "main": "detect-browser.js",

@@ -25,8 +25,19 @@ [![Build][build-image]][build-url]

OR (browserify):
```javascript
var SmartPhone = require('detect-mobile-browser')(false);
module.exports = (function($) {
$(document).ready(function() {
alert(SmartPhone.isAny());
});
})(jQuery);
```
**Usage Backend:-**
User as a ExpressJS middleware
Use as an ExpressJS middleware
```javascript
var mobileBrowser = require('./detect-browser');
var mobileBrowser = require('detect-mobile-browser');

@@ -71,2 +82,22 @@ ...

## List of detection functions:
- isAndroid
- isBlackBerry
- isBlackBerryPlayBook
- isBlackBerry10
- isIOS
- isIPhone
- isIPad
- isIPod
- isOpera
- isWindows
- isWindowsMobile
- isWindowsDesktop
- isFireFox
- isNexus
- isKindleFire
- isPalm
- isAny
[npm-image]: https://img.shields.io/npm/v/detect-mobile-browser.svg

@@ -73,0 +104,0 @@ [npm-download-image]: https://nodei.co/npm/detect-mobile-browser.png?downloads=true&downloadRank=true

@@ -18,2 +18,60 @@ var assert = require("assert");

});
describe('check module as a middleware', function(){
var mw = null;
var req = null;
var res = null;
beforeEach(function(){
mw = require('../detect-browser')(true);
req = {
headers: {
'user-agent': 'blah blah'
}
};
res = {
locals: {}
};
});
it('it should contain SmartPhone object', function(done){
mw(req, res, function(){
assert.equal(false, res.locals.SmartPhone.isAny());
done()
});
});
});
describe('check module all function as a middleware', function(){
userAgents.forEach(function(ua){
it('it should check: ' + ua['call'], function(done){
var mw = null;
var req = null;
var res = null;
mw = require('../detect-browser')(true);
req = {
headers: {
'user-agent': 'blah blah'
}
};
res = {
locals: {}
};
req.headers['user-agent'] = ua['userAgent'];
mw(req, res, function(){
assert.notEqual(null, res.locals.SmartPhone[ua['call']]());
done()
});
});
});
});
});

@@ -57,3 +57,15 @@ module.exports = [

'userAgent': 'Mozilla/4.0 (compatible; MSIE 6.0; Windows 95; PalmSource; Blazer 3.0) 16; 160x160'
},
{
'call': 'isAny',
'userAgent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 7_0 like Mac OS X; en-us) AppleWebKit/537.51.1 (KHTML, like Gecko) Version/7.0 Mobile/11A465 Safari/9537.53'
},
{
'call': 'isWindows',
'userAgent': 'Mozilla/5.0 (compatible; MSIE 9.0; Windows Phone OS 7.5; Trident/5.0; IEMobile/9.0'
},
{
'call': 'isIOS',
'userAgent': 'Mozilla/5.0 (iPad; CPU OS 7_0 like Mac OS X) AppleWebKit/537.51.1 (KHTML, like Gecko) Version/7.0 Mobile/11A465 Safari/9537.53'
}
];

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc