Merge pull request #6 from tantalor/master

Fixes nodejs require.
This commit is contained in:
Faisal Salman 2012-11-28 00:00:51 -08:00
commit 5cc6bf78a5
4 changed files with 18 additions and 1 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
node_modules/

View File

@ -17,6 +17,12 @@
"Faisal Salman <fyzlman@gmail.com>" "Faisal Salman <fyzlman@gmail.com>"
], ],
"main": "ua-parser", "main": "ua-parser",
"scripts": {
"test": "./node_modules/mocha/bin/mocha"
},
"devDependencies": {
"mocha": ">= 1.7.1"
},
"repositories": [ "repositories": [
{ {
"type": "git", "type": "git",

10
test.js Normal file
View File

@ -0,0 +1,10 @@
var assert = require("assert");
var UAParser = require("./ua-parser");
describe('getDevice', function () {
it('should return the model', function () {
var parser = new UAParser('Mozilla/5.0 (PlayBook; U; RIM Tablet OS 1.0.0; en-US) AppleWebKit/534.11 (KHTML, like Gecko) Version/7.1.0.7 Safari/534.11');
var device = parser.getDevice();
assert.equal(device.model, "PlayBook");
});
});

View File

@ -358,7 +358,7 @@
}; };
// check whether script is running inside node.js export as module // check whether script is running inside node.js export as module
if (typeof exports !== 'undefined' && this.toString() !== '[object DOMWindow]') { if (typeof exports !== 'undefined' && (!this || this.toString() !== '[object DOMWindow]')) {
if (typeof module !== 'undefined' && module.exports) { if (typeof module !== 'undefined' && module.exports) {
exports = module.exports = UAParser; exports = module.exports = UAParser;
} }