Use correct user-agent header by default (#1865)

This commit is contained in:
Josh Mock
2023-05-05 10:48:41 -05:00
committed by GitHub
parent b2b54f1ffe
commit bdb44d6d9a
2 changed files with 13 additions and 1 deletions

View File

@ -432,3 +432,12 @@ test('caFingerprint can\'t be configured over http / 2', t => {
)
t.end()
})
test('user agent is in the correct format', t => {
const client = new Client({ node: 'http://localhost:9200' })
const agentRaw = client.transport[symbols.kHeaders]['user-agent'] || ''
const agentSplit = agentRaw.split(/\s+/)
t.equal(agentSplit[0].split('/')[0], 'elasticsearch-js')
t.ok(/^\d+\.\d+\.\d+/.test(agentSplit[0].split('/')[1]))
t.end()
})