Coder Social home page Coder Social logo

Comments (3)

rguerreiro avatar rguerreiro commented on June 23, 2024

When the request comes with an unknown user-agent it returns 'phone' because there's an higher chance that it comes from a mobile device than from a desktop device (new phone OSes and devices appear on a monthly basis).

When there's no user-agent it returns 'desktop' because I'm assuming that it's an unusual situation (tests?) or some sort of an unknown device type. The best behavior (IMO) is to show as if I'm on a desktop.

But I like your suggestion on creating a config option. This way I'll add two: one to return when get an unknown user-agent and other for the default device (to be returned when there isn't an user-agent).

What do you think?

from express-device.

tbasse avatar tbasse commented on June 23, 2024

I like the way that I can set my own device types for both situations now.
But may I suggest you name the options more self-explanatory like this:

unknownUserAgentDeviceType
emptyUserAgentDeviceType

I find your current option names conflictive with your code. If your parser does not match a known agent I would expect it to return the default device type. But your defaultDeviceType would be returned when the user-agent is empty, which is more unlikely than an unknown agent.

from express-device.

rguerreiro avatar rguerreiro commented on June 23, 2024

done!

from express-device.

Related Issues (20)

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.