Giter Site home page Giter Site logo

ismobile's People

Contributors

bismarkhenao avatar dependabot-preview[bot] avatar igorlima avatar isruslan avatar kaimallea avatar knysakpatryk avatar kyuwoo-choi avatar lukasdrgon avatar mc-zone avatar orloffv avatar pivica avatar razzed avatar romainnorberg avatar samuli-hiltunen avatar shinnn avatar softwarespot avatar spotify-kai avatar toddsmithsalter avatar vomchik 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  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  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

ismobile's Issues

Serverside usage doesn't handle being passed undefined

we had a use case (have now fixed our side) where if you call

isMobile(undefined)

you get an error:

TypeError: Cannot read property 'use' of undefined
    at module.exports (/Users/aUser/Projects/sanitycheck/node_modules/isMobile/lib/isMobile.js:2:13)
    at Object.<anonymous> (/Users/aUser/Projects/sanitycheck/index.js:3:1)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Function.Module.runMain (module.js:501:10)
    at startup (node.js:129:16)
    at node.js:814:3

Amazon devices

Hi,

Would you be interested in a PR that adds explicit support for Amazon devices?

I would use this page as a reference.

Update usage examples for each use case

Per #96, clarify the usage with better examples for the most common use cases.

  • Drop-in CDN link with IIFE that creates a global isMobile object with results
  • CommonJS Interp
  • ESModule
  • Webpack

The automated release is failing 🚨

🚨 The automated release from the master branch failed. 🚨

I recommend you give this issue a high priority, so other packages depending on you could benefit from your bug fixes and new features.

You can find below the list of errors reported by semantic-release. Each one of them has to be resolved in order to automatically publish your package. I’m sure you can resolve this πŸ’ͺ.

Errors are usually caused by a misconfiguration or an authentication problem. With each error reported below you will find explanation and guidance to help you to resolve it.

Once all the errors are resolved, semantic-release will release your package the next time you push a commit to the master branch. You can also manually restart the failed CI job that runs semantic-release.

If you are not sure how to resolve this, here is some links that can help you:

If those don’t help, or if this issue is reporting something you think isn’t right, you can always ask the humans behind semantic-release.


Invalid npm token.

The npm token configured in the NPM_TOKEN environment variable must be a valid token allowing to publish to the registry https://registry.npmjs.org/.

If you are using Two-Factor Authentication, make configure the auth-only level is supported. semantic-release cannot publish with the default auth-and-writes level.

Please make sure to set the NPM_TOKEN environment variable in your CI with the exact value of the npm token.


Good luck with your project ✨

Your semantic-release bot πŸ“¦πŸš€

Symbian support

Is there any way I could include symbian support in your library? Your library is great by itself for modern times, but my company requires support for symbian, megoo and other stuff that's probabbly not in production anymore. πŸ˜ƒ

False Mobile Detection

I have laptop with a touch display. When the script executes it thinks it is a mobile browser.

Mozilla/5.0 (Windows NT 6.3; WOW64; Trident/7.0; Touch; MAGWJS; rv:11.0) like Gecko

To fix I removed the word touch from regular expression. I am unsure what this might of excluded for real mobile devices.

Windows Phone 10 is not detected

Windows Phone 10 is not correctly detected by this plugin.

isMobile.windows.device returns false

Mobile device model: Nokia Lumia 550
Operating system: Windows 10 Mobile
Browser: Microsoft Edge 38.14393.67.0

problem with webpack

The npm package doesn't have the same name as the AMD module (ismobilejs versus isMobile).
So when you use webpack, you have to create an alias.
I think it should be fine if you don't give a name to your AMD module (l132) :

define([], global.isMobile = instantiate());

instead of

define('isMobile', [], global.isMobile = instantiate());

redirect to .aspx ?

Hello,

This is my code:
var MOBILE_SITE = '/mobile/mobile.aspx', // site to redirect to
NO_REDIRECT = 'noredirect'; // cookie to prevent redirect

The redirect translates into:
..../mobile/index.html instead of ../mobile/mobile.aspx

Any thoughts?
tnx
frank

Tags and releases missing

The latest tag and release is 0.3.2, so with bower we can only install that version back from 2014-04-02
Please fix this, so we can use your package with bower!

Details:

$ bower install isMobile#0.3.4 --save
bower not-cached git://github.com/kaimallea/isMobile.git#0.3.4
bower resolve git://github.com/kaimallea/isMobile.git#0.3.4
bower ENORESTARGET No tag found that was able to satisfy 0.3.4

Additional error details:
Available versions: 0.3.2, 0.3.1, 0.3.0

Error on v1.0.2

isMobile.xxxxx on v1.0.2 returns undefined.

  • isMobile.any
  • isMobile.phone
  • isMobile.tablet

And isMobile.xxxxx.xxxxx returns following error.

Uncaught TypeError: Cannot read property 'phone' of undefined
  • isMobile.apple.phone
  • isMobile.apple.ipod
  • isMobile.apple.tablet
  • isMobile.apple.device (any mobile Apple device)
  • isMobile.android.phone
  • isMobile.android.tablet
  • isMobile.android.device (any mobile Android device; OkHttp user agents will match this)
  • isMobile.amazon.phone
  • isMobile.amazon.tablet
  • isMobile.amazon.device (any mobile Amazon Silk device)
  • isMobile.windows.phone
  • isMobile.windows.tablet
  • isMobile.windows.device (any mobile Windows device)
  • isMobile.other.blackberry_10
  • isMobile.other.blackberry
  • isMobile.other.opera (Opera Mini)
  • isMobile.other.firefox
  • isMobile.other.chrome
  • isMobile.other.device (any "Other" device)

Related #94

Suggestion - Screen Resolution

You should add resolution detection for redirect. My android tablet is showing up as mobile but it is a HD screen. Anything with a resolution above 1280 x 800 should show as a tablet.

nodejs usage causes navigator error

when trying to run ismobile as an npm module in nodejs there is an error returned:

ReferenceError: navigator is not defined
    at IsMobileClass (/Users/aUser/Projects/sanitycheck/node_modules/ismobilejs/isMobile.js:58:31)
    at Object.<anonymous> (/Users/aUser/Projects/sanitycheck/index.js:3:1)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Function.Module.runMain (module.js:501:10)
    at startup (node.js:129:16)
    at node.js:814:3

Error 'split not a function' in iOS 9.3.2 Safari

Hi Kai,
We ran into error as 'split not a function' in iOS 9.3.2 Safari. In javascript, navigator.userAgent returns false as a boolean value, which doens't have 'split' function while it was called later. Temporarily we changed code in version 0.4.1 as below from:
var ua = userAgent || navigator.userAgent
to:
var ua = userAgent || navigator.userAgent || '';
Just let you know.

Thanks
Li

Vulnerable Regular Expression

There are multiple regular expression used for parsing the user agent which are vulnerable to ReDoS, e.g.:

/(?=.*\bAndroid\b)(?=.*\bSD4930UR\b)/i

The slowdown is relatively serious because multiple such regexs are checked against the user agent: for 40.000 characters around 22 seconds matching time. I would suggest one of the following:

  • remove the regex,
  • anchor the regex,
  • limit the number of characters that can be matched by the repetition,
  • limit the input size.

If needed, I can provide an actual example showing the slowdown.

Re-write using CoffeScript

What you think to rewrite the library using CoffeeScript? We could start by Jasmine code.
Let me know what you think about this idea.

v^1.xx.xx doesn't support ssr in react by referencing window

v0.5.1 does call window reference and handles it if it doesn't exist.

in v^1.xx.xx it calls window which doesn't allow ssr.

For those wondering any ANT DESIGN users who use the latest version (^3.23.1) ismobilejs is used by some packages and has updated to ismobilejs v1.xx.xx.

In your package.json in resolutions place ismobilejs as 0.5.1 for ssr

License?

Hey! I am assuming this is under the MIT license, but for sake use in projects you should include and official license file!

Detect when change resolution

Today, I'm using the current production version. When I'm testing on Chrome and changing phone to tablet, or phone to desktop, the plugin do not detect this changes.

This is just an improvement, but can be useful.

'ismobilejs' import is an empty object

Hello,
After upgrading ismobilejs version from v0.5.2, which is present on NPM but not in github releases btw, to v1.0.1 the result of webpacks import function is {}.
Executed in mounted hook of js framework, used in browser, built with webpack.

  const { default: isMobile } = await import('ismobilejs');
  console.log(isMobile); //> {}

Thank you in advance!

Using ES6 import the return is a function

Using ES6 import is needed to run as a function to work.

Ex:

import React from 'react';
import isMobile from 'ismobilejs';

const Navbar = () => {
  const navbarColllapseTarget = isMobile().phone ? '#nav-search-user' : '';
  return (...);
}

export default Navbar;

This works: isMobile().phone
This does not: isMobile.phone

In documentation is specified to use isMobile as an Object. In a previous project, I used as an Object.

Maybe I'm doing something wrong, I don't know.

Can not detect chrome for android

Thank you for your project,I tested a lot, It's "false" use "isMobile.android.phone" or "isMobile.phone" in chrome for android.thank you!

navigator is not defined (node.js)

Some time error occurs:

ReferenceError: navigator is not defined
 at IsMobileClass (/node_modules/ismobilejs/isMobile.js:55:31)

I think because in node.js no 'navigator.userAgent' variable.

Cannot set property 'isMobile' of undefined

Hi,

Thank you for this great library :).
After adding this library to my website, I got the below error
Uncaught TypeError: Cannot set property 'isMobile' of undefined
please advise

Thanks

Restructuring the module

How about opting for the universal style of defining a module e.g.

(function isMobileModule(root, factory) {
    // Define the UMD structure
})(window, (function isMobileInterface() {
    // Define the module itself
}));

If you would like me to send a PR let me know.

Unnecessary backslash in `other_firefox` expression

ESLint generates an error for the other_firefox RegExp pattern:

	 Error     19,24: Unnecessary escape character: \M. (no-useless-escape)

The fix is to remove the unnecessary backslash in front of the M here.

- other_firefox = /\Mobile(?:.+)Firefox\b/i; // Match 'Mobile' AND 'Firefox'
+ other_firefox = /Mobile(?:.+)Firefox\b/i; // Match 'Mobile' AND 'Firefox'

I've created a PR to fix this issue.

Facebook mobile (ipad) app detected incorrectly as phone

Facebook Ipad app has an integrated browser, which user agent contains a lot of things:

Mozilla/5.0 (iPad; CPU OS 8_1 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Mobile/12B410 [FBAN/FBIOS;FBAV/20.1.0.15.10;FBBV/5758778;FBDV/iPad5,4;FBMD/iPad;FBSN/iPhone OS;FBSV/8.1;FBSS/2; FBCR/;FBID/tablet;FBLC/fi_FI;FBOP/1]

Regexp for Phone detection catches "iPhone OS" -> incorrect detection

The easiest fix is propably to remove anything after [FBAN, like this:

  var ua = userAgent || navigator.userAgent;
  var tmp   = ua.split("[FBAN");
  if (typeof tmp[1] != "undefined") { ua = tmp[0];  }

Upgrade/update to ES6

Hi @kaimallea I'm using this lib, it's awesome.

Is there any plan to rewrite it using ES6 features, and then browserify to generate an dist file?

[]s

isMobile.any doesn't work recently...

I used to write if(isMobile.any){...}, but somehow it doesn't work anymore, I have to do if(isMobile.any()){...} instead to make it work.

but there is one thing that is more wierder, all my old projects that running on the server are all fine with if(isMobile.any){...}

can you help me with this issue. thank you so much.

Error for Mozilla Mobile agent

With this agent:
Mozilla/5.0 (Android; Mobile; rv:27.0) Gecko/27.0 Firefox/27.0
I get javascript error:
No match with webkitVersion
ua.match(webkitVersion)

Does not work with iOS webview

On iOS webview the useragent is not set.

Option to remedy this is to add a custom useragent setter inside ismobile. So that one can add own mobile user agents.

EDIT Probably not something that should be done. Closing issue after thoughts

Can not detect Edge on windows 10 and windows 10 mobile

Desktop User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.79 Safari/537.36 Edge/14.14393

Phone User-Agent: Mozilla/5.0 (Windows Phone 10.0; Android 4.2.1; Microsoft; Lumia 650) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2486.0 Mobile Safari/537.36 Edge/14.14263

(Requirejs) Using r.js to combine AMD files include isMobile.js throw error: Mismatched anonymous define() module: [object Object]

I'm not sure this is an issue or just my wrong.
At first, I include isMobile.js in my AMD project use the following code, it worked very well.

require( [ "app", "isMobile" ], function(App, isMobile) {
    //...
});

But when I use r.js to optimize and combine my project and run again, the following error has occurred.

Mismatched anonymous define() module: [object Object]

Then I found the description of this error form the page of requirejs .
So I think the problem may be in the line #105~106 of isMobile.js:

 //AMD
define(global.isMobile = instantiate());

I tried to modify the code to look like this:

//AMD
define( 'isMobile', [], global.isMobile = instantiate() );

Then it worked fine.

So I just submit this issue, and I'm not a veteran of the requirejs, anyone could give me some advice on this?

Btw, very nice project :).

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.