Giter VIP home page Giter VIP logo

express-device's Issues

Huge ReadME string is stored in memory

There's something weird going on with the publish history of this module. I cleaned my npm cache to make sure the issue wasn't on my end. When I install this module I get a package.json with the correct latest version 0.3.9 but it has a completely different JSON that includes the readme string. https://gist.github.com/esco/036ed9e2e374fa268e3b

The package.json in the master branch is fine because it doesn't have the "readme" field and when I download the tgz direclty it doesn't have it either.

Both package.json files have "version": "0.3.9".

The problem with this is that when express-device is required, the contents of ReadME.md are stored in require.cache which is a waste of memory.

Is anyone able to replicate this?

Docs incorrect

In the docs you list that emptyUserAgentDeviceType defaults to phone and unknownUserAgentDeviceType defaults to desktop but looking at your code I see the opposite.

Not sure if you're ever going to work on this code again, but in case someone else wants to use it and gets into the same issue I had

app.enableDeviceHelpers() and app.enableViewRouting() do not work

Hello, I have tried running the example application, and when I do, the following error stack is produced:

    app.enableDeviceHelpers();
        ^
TypeError: Object function app(req, res, next){ app.handle(req, res, next); } has no method 'enableDeviceHelpers'
    at Function.<anonymous> (/Users/ajay/Sites/pipeline/carbon/node/test.js:17:9)
    at Function.app.configure (/Users/ajay/Sites/pipeline/node_modules/express/lib/application.js:395:61)
    at Object.<anonymous> (/Users/ajay/Sites/pipeline/carbon/node/test.js:7:5)
    at Module._compile (module.js:449:26)
    at Object.Module._extensions..js (module.js:467:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.runMain (module.js:492:10)
    at process.startup.processNextTick.process._tickCallback (node.js:245:9)

It seems the two functions are not binding to express.application properly. I am using express 3.1.1.

README a bit confusing (parseUserAgent default)

This line:

Example: iPhone. If the option parseUserAgent is set to false, then it will return an empty string

Makes it seem like the default is true. At least to me. Totally your call. I'd suggest:

Example: iPhone. parseUserAgent is set to false by default and will return an empty string.

Request with iPad Safari is detected as desktop

Device type is returned as desktop in Safari, user agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.1.1 Safari/605.1.15

But correctly as tablet in Chrome on the same device, user agent:
Mozilla/5.0 (iPad; CPU OS 14_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/91.0.4472.80 Mobile/15E148 Safari/604.1

code markup with Native Node.js

How to use it with native Node.js with res.write and create server only (without Express and ejs)?

example:

const device = require('express-device')

http.createServer(function(req, res) {
  res.writeHead('blablabla')
  if (is_desktop) {
     res.write('hi desktop)
  }
  res.end()
}

thanks in advance

Facebook scraper detected as Mobile device

I make a simple patch in my node / express project

if(req.device.type != 'phone' || req.headers['user-agent'].indexOf('facebookexternalhit') !== -1) {
lang.page = '/';
res.render('index',lang);
} else {
lang.page = '/';
res.render('mobile/index',lang);
}

[DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.

$ yarn add express-device
yarn add v1.9.4
[1/4] Resolving packages...
[2/4] Fetching packages...
[-----------------------------------------------------------------------------------------------------------------] 0/881(node:18575) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
info [email protected]: The platform "linux" is incompatible with this module.
info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Saved lockfile.
success Saved 4 new dependencies.
info Direct dependencies
└─ [email protected]
info All dependencies
├─ [email protected]
├─ [email protected]
├─ [email protected]
└─ [email protected]
Done in 60.49s.

Hi, I am trying to use this library to support SSR (reference: mui/material-ui#6068 (comment)). I got the warning above, thought sharing with you.

What new features should I include for version 0.4?

One that is on the pipeline for a very long time is parsing the OS. But that is already done in the ua-parser package. Is it really necessary on the express-device?

What other ideas do you have that make sense on adding to express-device?

Typescript support

Hey there

I've been using express for quite some time and recently switched to typescript.
The express-device package was always a must have for all my applications but now, i am missing the lack of typescript support.

Are there plans to create such support?
Thanks in advance.

Greetings

Small issue

This is more likely my goof up but I keep getting the message "device not defined".

I ran npm install express-device

the added this line to my server.js

app.use(device.capture());

I am also using express 3.

Googlebot on smartphone classified as "phone" instead of "bot"

I'm seeing the following user agents being detected as "phone":

Mozilla/5.0 (iPhone; CPU iPhone OS 8_3 like Mac OS X) AppleWebKit/537.36 (KHTML, like Gecko) Version/8.0 Mobile/12F70 Safari/600.1.4 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)

Mozilla/5.0 (iPhone; CPU iPhone OS 83 like Mac OS X) AppleWebKit/600.1.4 (KHTML like Gecko) Version/8.0 Mobile/12F70 Safari/600.1.4 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)

More complete list here:
https://support.google.com/webmasters/answer/1061943?hl=en

Seems to me they should be categorized as "bot" to be consistent with the fact bot-ness trumps device type for desktop. What do you think?

Support car device type

Mozilla/5.0 (X11; u; Linux; C) AppleWebKit /533.3 (Khtml, like Gheko) QtCarBrowser Safari /533.3

npm install failure on Windows Azure

maybe windows azure and some hosting services not support npm install using git...
dependent public npm repogitory. it's better support some cloud platforms.

i attach windows azure error log.

thank you. your module. it's very good. 👍

npm http GET http://registry.npmjs.org/express-device
npm http GET http://registry.npmjs.org/coffee-script
npm http 200 http://registry.npmjs.org/coffee-script
npm http GET http://registry.npmjs.org/coffee-script/-/coffee-script-1.6.1.tgz
npm http 200 http://registry.npmjs.org/express-device
npm http GET http://registry.npmjs.org/express-device/-/express-device-0.3.5.tgz
npm http 200 http://registry.npmjs.org/coffee-script/-/coffee-script-1.6.1.tgz
npm http 200 http://registry.npmjs.org/express-device/-/express-device-0.3.5.tgz
npm ERR! git clone git://github.com/publicclass/express-partials.git CreateProcessW: The system cannot find the file specified.
npm ERR! Error: `git "clone" "git://github.com/publicclass/express-partials.git" "C:\\DWASFiles\\Sites\\ssen\\Temp\\npm-13516\\1362820148766-0.6230687508359551"` failed with 127
npm ERR!     at ChildProcess.<anonymous> (D:\Program Files (x86)\nodejs\node_modules\npm\lib\utils\exec.js:56:20)
npm ERR!     at ChildProcess.emit (events.js:70:17)
npm ERR!     at maybeExit (child_process.js:358:16)
npm ERR!     at Socket.<anonymous> (child_process.js:463:7)
npm ERR!     at Socket.emit (events.js:67:17)
npm ERR!     at Array.<anonymous> (net.js:335:10)
npm ERR!     at EventEmitter._tickCallback (node.js:190:38)
npm ERR!  [Error: `git "clone" "git://github.com/publicclass/express-partials.git" "C:\\DWASFiles\\Sites\\ssen\\Temp\\npm-13516\\1362820148766-0.6230687508359551"` failed with 127]
npm ERR! You may report this log at:
npm ERR!     <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR!     <[email protected]>

npm ERR! System Windows_NT 6.1.7601
npm ERR! command "D:\\Program Files (x86)\\nodejs\\\\node.exe" "D:\\Program Files (x86)\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "--production"
npm ERR! cwd C:\DWASFiles\Sites\ssen\VirtualDirectory0\site\wwwroot
npm ERR! node -v v0.6.20
npm ERR! npm -v 1.1.37
npm ERR! message `git "clone" "git://github.com/publicclass/express-partials.git" "C:\\DWASFiles\\Sites\\ssen\\Temp\\npm-13516\\1362820148766-0.6230687508359551"` failed with 127
npmSetConsoleTitleW: The operation completed successfully.

make 'desktop' default device.type or allow setting of default device via option

When a unknown user-agent requests a ressource, it gets detected as mobile. When no user-agent is set at all, it gets detected as desktop. That's not very consistent in my opinion.

The default device.type should be set to 'desktop' (makes it consistent with no user-agent set). Alternatively, we could expose an option to let us set the default device.type on initialization.

ubuntu install using NPM failure

I posted my error code below. This occurred from a ubuntu instance on ec2. You guy probably just need to update the registry.

npm http GET https://registry.npmjs.org/express-device npm http 304 https://registry.npmjs.org/express-device npm WARN git config --get remote.origin.urlreturned wrong result (git://github.com/publicclass/express-partials.git) execvp(): No such file or directory npm ERR! git clone git://github.com/publicclass/express-partials.git execvp(): No such file or directory npm ERR! Error:git "clone" "--mirror" "git://github.com/publicclass/express-partials.git" "/home/ubuntu/.npm/_git-remotes/git-github-com-publicclass-express-partials-git-4988eaf2" failed with 127

FTLOG please added example of in-Express use

can someone please add an example of how this works in Express itself

app.use(device.capture());

app.use(function(req,res,next){
   device.is_desktop ///  no indication that this is valid, please include example
   device.is_mobile /// no indication that this is valid, please include example to keep us from guessing
});

wget shows up as a phone

Thanks for your useful library, however there is one small issue: wget seems to be interpreted as a 'phone,' and I think it should be a 'bot.' Here is what I get when wgetting a simple page which simply res.sends the req.device:

{"parser":{"options":{"emptyUserAgentDeviceType":"desktop","unknownUserAgentDeviceType":"phone","botUserAgentDeviceType":"bot","carUserAgentDeviceType":"car","parseUserAgent":true},"useragent":{"family":"Wget","major":"1","minor":"16","patch":"3","device":{"family":"Other","major":"0","minor":"0","patch":"0"},"os":{"family":"Other","major":"0","minor":"0","patch":"0"}}},"type":"phone","name":"Other"} 

If I perform the same experiment using curl, then it correctly returns as a bot.

This was tested using: [email protected] [email protected] and [email protected]

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.