Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
juliangruber committed Aug 7, 2013
0 parents commit 206d8c8
Show file tree
Hide file tree
Showing 5 changed files with 97 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
52 changes: 52 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@

# is-mobile

Check if mobile browser, based on useragent string.

## Example

```js
var mobile = require('is-mobile');

console.log(mobile(navigator.userAgent));
// => false
```

## Installation

With [npm](https://npmjs.org) do:

```bash
npm install is-mobile
```

Bundle for the browser with
[browserify](https://github.com/substack/node-browserify).

## Kudos

Taken from [detectmobilebrowsers.com](http://detectmobilebrowsers.com/).

## License

(MIT)

Copyright (c) 2013 Julian Gruber <julian@juliangruber.com>

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
6 changes: 6 additions & 0 deletions index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 30 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"name": "is-mobile",
"description": "Check if mobile browser.",
"version": "0.0.0",
"repository": {
"type": "git",
"url": "git://github.com/juliangruber/is-mobile.git"
},
"homepage": "https://github.com/juliangruber/is-mobile",
"main": "index.js",
"scripts": {
"test": "tape test.js"
},
"dependencies": {},
"devDependencies": {
"tape": "~1.0.4"
},
"keywords": [
"mobile",
"desktop",
"check",
"browser"
],
"author": {
"name": "Julian Gruber",
"email": "mail@juliangruber.com",
"url": "http://juliangruber.com"
},
"license": "MIT"
}
8 changes: 8 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
var test = require('tape');
var isMobile = require('./');

test('is mobile', function (t) {
t.ok(isMobile('Mozilla/5.0 (iPhone; CPU iPhone OS 5_0 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9A334 Safari/7534.48.3'));
t.notOk(isMobile('Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.95 Safari/537.36'));
t.end();
});

0 comments on commit 206d8c8

Please sign in to comment.