Skip to content

Commit

Permalink
Fix passing a custom User-Agent to Axios. (#562)
Browse files Browse the repository at this point in the history
Co-authored-by: David Patrick <[email protected]>
  • Loading branch information
djanowski and davidpatrick authored Jan 5, 2021
1 parent b116636 commit 88cdaa9
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion docs/auth_index.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ <h1 class="page-title">auth/index.js</h1>
}

var defaultHeaders = {
'User-agent': 'node.js/' + process.version.replace('v', ''),
'User-Agent': 'node.js/' + process.version.replace('v', ''),
'Content-Type': 'application/json'
};

Expand Down
2 changes: 1 addition & 1 deletion docs/management_index.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ <h1 class="page-title">management/index.js</h1>
var userAgent = options.userAgent || 'node.js/' + process.version.replace('v', '');

var defaultHeaders = {
'User-agent': 'node.js/' + process.version.replace('v', ''),
'User-Agent': 'node.js/' + process.version.replace('v', ''),
'Content-Type': 'application/json'
};

Expand Down
2 changes: 1 addition & 1 deletion src/auth/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ var AuthenticationClient = function(options) {
}

var defaultHeaders = {
'User-agent': 'node.js/' + process.version.replace('v', ''),
'User-Agent': 'node.js/' + process.version.replace('v', ''),
'Content-Type': 'application/json'
};

Expand Down
2 changes: 1 addition & 1 deletion src/management/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ var ManagementClient = function(options) {
var userAgent = options.userAgent || 'node.js/' + process.version.replace('v', '');

var defaultHeaders = {
'User-agent': 'node.js/' + process.version.replace('v', ''),
'User-Agent': 'node.js/' + process.version.replace('v', ''),
'Content-Type': 'application/json'
};

Expand Down
4 changes: 2 additions & 2 deletions test/auth/authentication-client.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ describe('AuthenticationClient', function() {
domain: 'auth0.com'
});

var expected = { 'User-agent': 'node.js/' + process.version.replace('v', '') };
var expected = { 'User-Agent': 'node.js/' + process.version.replace('v', '') };

expect(client.oauth.oauth.options.headers).to.contain(expected);
expect(client.database.dbConnections.options.headers).to.contain(expected);
Expand All @@ -161,7 +161,7 @@ describe('AuthenticationClient', function() {

it('should include additional headers when provided', function() {
var customHeaders = {
'User-agent': 'my-user-agent',
'User-Agent': 'my-user-agent',
'Another-header': 'test-header'
};

Expand Down
6 changes: 3 additions & 3 deletions test/management/management-client.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,13 +210,13 @@ describe('ManagementClient', function() {
expect(
client[manager.property].resource.restClient.restClient.options.headers
).to.contain({
'User-agent': 'node.js/' + process.version.replace('v', '')
'User-Agent': 'node.js/' + process.version.replace('v', '')
});
});

it(manager + ' should include additional headers when provided', function() {
var customHeaders = {
'User-agent': 'my-user-agent',
'User-Agent': 'my-user-agent',
'Another-header': 'test-header'
};

Expand All @@ -226,7 +226,7 @@ describe('ManagementClient', function() {
expect(
client[manager.property].resource.restClient.restClient.options.headers
).to.contain({
'User-agent': 'my-user-agent',
'User-Agent': 'my-user-agent',
'Another-header': 'test-header'
});
});
Expand Down
2 changes: 1 addition & 1 deletion test/management/management-token-provider.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ describe('ManagementTokenProvider', function() {
it('should set headers when passed into options', function() {
var config = Object.assign({}, defaultConfig);
config.headers = {
'User-agent': 'node.js',
'User-Agent': 'node.js',
'Content-Type': 'application/json'
};
var provider = new ManagementTokenProvider(config);
Expand Down
18 changes: 9 additions & 9 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
var Webpack = require('webpack');
var pkg = require('./package.json');
var pkg = require('./package.json');

var StringReplacePlugin = require("string-replace-webpack-plugin");
var StringReplacePlugin = require('string-replace-webpack-plugin');

module.exports = {
entry: './src/index.js',
output: {
path: './build',
filename: pkg.name+'-'+pkg.version+'.min.js',
filename: pkg.name + '-' + pkg.version + '.min.js',
library: 'Auth0',
libraryTarget: 'umd',
libraryTarget: 'umd'
},
node: {
Buffer: true,
Expand All @@ -27,10 +27,10 @@ module.exports = {
loader: StringReplacePlugin.replace({
replacements: [
{
// Remove User-agent for browser version
pattern: /'User-agent': 'node\.js/gmi,
replacement: function (match, p1, offset, string) {
return "// 'User-agent': 'node.js";
// Remove User-Agent for browser version
pattern: /'User-Agent': 'node\.js/gim,
replacement: function(match, p1, offset, string) {
return "// 'User-Agent': 'node.js";
}.bind(this)
}
]
Expand All @@ -50,6 +50,6 @@ module.exports = {
resolve: {
modulesDirectories: ['node_modules'],
root: __dirname,
alias: {},
alias: {}
}
};

0 comments on commit 88cdaa9

Please sign in to comment.