New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

browserType

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

browserType - npm Package Compare versions

Comparing version 0.1.0 to 0.2.0

31

lib/browserType.js
module.exports = function browserType(){
return function(req,res,next){
req.isIE =
req.isIE6 =
req.isIE7 =
req.isIE8 =
req.isIE9 =
req.isIE10 =
req.isChrome =
req.isOpera =
req.isFirefox =
req.isSafari = false;
var ua = req.headers['user-agent'];

@@ -8,23 +20,38 @@ var bt = ""

bt = 'ie6'
req.isIE = true;
req.isIE6 = true;
}else if(ua.indexOf('MSIE 7') !=-1){
bt = 'ie7'
req.isIE = true;
req.isIE7 = true;
}else if(ua.indexOf('MSIE 8') != -1 ){
bt = 'ie8'
req.isIE = true;
req.isIE8 = true;
}else if(ua.indexOf('MSIE 9') != -1){
bt = 'ie9'
req.isIE = true;
req.isIE9 = true;
}else if(ua.indexOf('MSIE 10') != -1){
bt = 'ie10'
req.isIE = true;
req.isIE10 = true;
}else if(ua.indexOf('Chrome') != -1){
bt = 'chrome'
req.isChrome = true;
}else if(ua.indexOf('Chrome') == -1 && ua.indexOf('Safari') != -1){
bt = 'safari'
req.isSafari = true;
}else if(ua.indexOf('Firefox') != -1){
bt = 'firefox'
req.isFirefox = true;
}else if(ua.indexOf('Opera') != -1){
bt = 'opera'
req.isOpera = true;
}
req.browserType = bt;
req.browser = req.browserType = bt;
next();
}
}

2

package.json

@@ -5,3 +5,3 @@ {

"description": "to determine the browser type, this is a middleware of connect.",
"version": "0.1.0",
"version": "0.2.0",
"homepage": "https://github.com/brighthas/browserType-connect",

@@ -8,0 +8,0 @@ "repository": {

@@ -8,2 +8,6 @@ browserType-connet

npm install browserType
or
cd node_modules

@@ -21,3 +25,3 @@ git clone https://github.com/brighthas/browserType-connect.git browserType

app.get('/',function(req,res){
res.send(req.browserType)
res.send(req.browserType) // or req.browser
})

@@ -35,1 +39,19 @@

# API
# req.isIE
# req.isIE6
# req.isIE7
# req.isIE8
# req.isIE9
# req.isIE10
# req.isChrome
# req.isFirefox
# req.isSafari
# req.browser
# req.browserType
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