Skip to content

Commit

Permalink
👌 Handle sites with subdomains
Browse files Browse the repository at this point in the history
  • Loading branch information
webNeat committed Dec 2, 2020
1 parent 0758cb1 commit 48a0ffc
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
10 changes: 10 additions & 0 deletions packages/core/src/domain/configuration.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,16 @@ describe('configuration', () => {
expect(configuration.isIntakeUrl('https://trace.browser-intake-datadoghq.com/v1/input/xxx')).toBe(true)
})

it('should handle sites with subdomains', () => {
const configuration = buildConfiguration(
{ clientToken, site: 'us3.datadoghq.com', useAlternateIntakeDomains: true },
usEnv
)
expect(configuration.isIntakeUrl('https://rum.browser-intake-us3-datadoghq.com/v1/input/xxx')).toBe(true)
expect(configuration.isIntakeUrl('https://logs.browser-intake-us3-datadoghq.com/v1/input/xxx')).toBe(true)
expect(configuration.isIntakeUrl('https://trace.browser-intake-us3-datadoghq.com/v1/input/xxx')).toBe(true)
})

it('should detect proxy intake request', () => {
let configuration = buildConfiguration({ clientToken, proxyHost: 'www.proxy.com' }, usEnv)
expect(configuration.isIntakeUrl('https://www.proxy.com/v1/input/xxx')).toBe(true)
Expand Down
4 changes: 3 additions & 1 deletion packages/core/src/domain/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,9 @@ function getEndpoint(
function getHost(intakeType: IntakeType, endpointType: EndpointType, site: string) {
const middleDomain = INTAKE_MIDDLE_DOMAINS[intakeType]
const endpoint = ENDPOINTS[intakeType][endpointType]
return `${endpoint}${middleDomain}${site}`
const domainParts = site.split('.')
const ext = domainParts.pop()
return `${endpoint}${middleDomain}${domainParts.join('-')}.${ext}`
}

function getIntakeUrls(intakeType: IntakeType, conf: TransportConfiguration, withReplica: boolean) {
Expand Down

0 comments on commit 48a0ffc

Please sign in to comment.