diff --git a/src/node/index.js b/src/node/index.js index 87ca7a84f..172e9966b 100644 --- a/src/node/index.js +++ b/src/node/index.js @@ -21,7 +21,6 @@ const semver = require('semver'); const safeStringify = require('fast-safe-stringify'); const utils = require('../utils'); -const pkg = require('../../package.json'); const RequestBase = require('../request-base'); const { unzip } = require('./unzip'); const Response = require('./response'); @@ -132,14 +131,11 @@ exports.buffer = {}; * @api private */ function _initHeaders(req) { - const ua = `node-superagent/${pkg.version}`; req._header = { // coerces header names to lowercase - 'user-agent': ua }; req.header = { // preserves header name case - 'User-Agent': ua }; } diff --git a/test/node/user-agent.js b/test/node/user-agent.js index 1254419a4..8f835d88a 100644 --- a/test/node/user-agent.js +++ b/test/node/user-agent.js @@ -6,32 +6,9 @@ const setup = require('../support/setup'); const base = setup.uri; describe('req.get()', () => { - it('should set a default user-agent', () => + it('should not set a default user-agent', () => request.get(`${base}/ua`).then(res => { assert(res.headers); - assert(res.headers['user-agent']); - assert( - /^node-superagent\/\d+\.\d+\.\d+(?:-[a-z]+\.\d+|$)/.test( - res.headers['user-agent'] - ) - ); + assert(!res.headers['user-agent']); })); - - it('should be able to override user-agent', () => - request - .get(`${base}/ua`) - .set('User-Agent', 'foo/bar') - .then(res => { - assert(res.headers); - assert.equal(res.headers['user-agent'], 'foo/bar'); - })); - - it('should be able to wipe user-agent', () => - request - .get(`${base}/ua`) - .unset('User-Agent') - .then(res => { - assert(res.headers); - assert.equal(res.headers['user-agent'], void 0); - })); });