Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added os-name package #2

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ $ npm install default-user-agent
var ua = require('default-user-agent');

// darwin
console.log(ua()); // 'node/v0.11.11 (darwin 13.1.0; x64)'
console.log(ua('urllib', '0.0.1')); // 'urllib/0.0.1 node/v0.11.11 (darwin 13.1.0; x64)'
console.log(ua()); // 'Node.js/0.11.15 (OS X Yosemite; x64)'
console.log(ua('urllib', '0.0.1')); // 'urllib/0.0.1 Node.js/0.11.15 (OS X Yosemite; x64)'

// linux
// 'node/v0.11.11 (linux 3.11.0-12-generic; x64)'
// 'Node.js/0.11.15 (Linux 3.13; x64)'
```

## License
Expand Down
7 changes: 3 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,10 @@
* Module dependencies.
*/

var os = require('os');
var osName = require('os-name');

var USER_AGENT = 'node/' + process.version
+ ' (' + process.platform + ' ' + os.release()
+ '; ' + process.arch + ')';
var USER_AGENT = 'Node.js/' + process.version.slice(1)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about using process.release nodejs/node#493 to support io.js also?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, that's pretty new. They're not even sure yet where to put it and I don't see any examples of what its value would look like either. However, yes, supporting this would be a great idea when it's available.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That new process.release Object should no longer be necessary now that io.js and Node.js have merged: http://www.infoq.com/news/2015/05/nodejs-iojs

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, that new stuff was added to io.js v3.0.0, but what good is it to us when io.js is officially Node.js now?

+ ' (' + osName() + '; ' + process.arch + ')';

module.exports = function ua(name, version) {
if (arguments.length !== 2) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
}
},
"dependencies": {

"os-name": "*"
},
"devDependencies": {
"autod": "*",
Expand Down
8 changes: 4 additions & 4 deletions test/default-user-agent.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ describe('default-user-agent.test.js', function () {
var s = ua();
s.should.be.a.String;
s.should.match(/\w+\/\w+/);
// 'node/v0.11.11 (darwin 13.1.0; x64)'
s.should.match(/^node\/v\d\.\d+\.\d+ \(\w+ .+; \w+\)$/);
// 'Node.js/0.11.15 (OS X Yosemite; x64)'
s.should.match(/^Node\.js\/\d\.\d+\.\d+ \(\w+ .+; \w+\)$/);
});

it('should got custom user agent string', function () {
var s = ua('urllib', '0.1.1');
s.should.be.a.String;
s.should.match(/\w+\/\w+/);
// 'node/v0.11.11 (darwin 13.1.0; x64)'
s.should.match(/^urllib\/0\.1\.1 node\/v\d\.\d+\.\d+ \(\w+ .+; \w+\)$/);
// 'Node.js/0.11.15 (OS X Yosemite; x64)'
s.should.match(/^urllib\/0\.1\.1 Node\.js\/\d\.\d+\.\d+ \(\w+ .+; \w+\)$/);
});
});