Skip to content

Commit

Permalink
👌 improve same origin check
Browse files Browse the repository at this point in the history
  • Loading branch information
bcaudan committed Feb 26, 2020
1 parent 88edf9d commit 13b2ffa
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
4 changes: 0 additions & 4 deletions packages/core/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,6 @@ function hasToJSON(value: unknown): value is ObjectWithToJSON {
return typeof value === 'object' && value !== null && value.hasOwnProperty('toJSON')
}

export function startsWith(candidate: string, search: string) {
return candidate.indexOf(search) === 0
}

export function includes(candidate: unknown[], search: unknown) {
return candidate.indexOf(search) !== -1
}
Expand Down
4 changes: 2 additions & 2 deletions packages/rum/src/resourceUtils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { addMonitoringMessage, Configuration, includes, msToNs, ResourceKind, startsWith } from '@datadog/browser-core'
import { addMonitoringMessage, Configuration, includes, msToNs, ResourceKind } from '@datadog/browser-core'

import { PerformanceResourceDetails } from './rum'

Expand Down Expand Up @@ -98,5 +98,5 @@ function isBrowserAgentRequest(url: string, configuration: Configuration) {
}

function haveSameOrigin(url1: string, url2: string) {
return startsWith(url2, new URL(url1).origin)
return new URL(url1).origin === new URL(url2).origin
}

0 comments on commit 13b2ffa

Please sign in to comment.