Skip to content

Commit

Permalink
changed default GOT user-agent
Browse files Browse the repository at this point in the history
  • Loading branch information
Alessandro100 committed Apr 10, 2024
1 parent b3d2358 commit d19ec05
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions gbfs-validator/gbfs.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const got = require('got')
const validate = require('./validate')
var packageJson = require('./package.json');
const validatorVersion = process.env.COMMIT_REF
? process.env.COMMIT_REF.substring(0, 7)
: require('./package.json').version
Expand Down Expand Up @@ -281,6 +282,8 @@ class GBFS {
throw new Error('Missing URL')
}

const userAgent = `MobilityData GBFS-Validator/${packageJson?.version} (Node ${process?.versions['node']})`

this.url = url
this.options = {
docked,
Expand All @@ -289,7 +292,11 @@ class GBFS {
}
this.auth = auth

this.gotOptions = {}
this.gotOptions = {
headers: {
'user-agent': userAgent
}
}

if (this.auth && this.auth.type) {
if (this.auth.type === 'basic_auth' && this.auth.basicAuth) {
Expand All @@ -308,7 +315,9 @@ class GBFS {
}

if (this.auth.type === 'headers') {
this.gotOptions.headers = {}
this.gotOptions.headers = {
'user-agent': userAgent
}
for (var header of this.auth.headers) {
if (header && header.value) {
this.gotOptions.headers[header.key] = header.value
Expand Down

0 comments on commit d19ec05

Please sign in to comment.