✨RUM-16635 Add wildcard host pattern matching to WebView event bridge#4703
Open
barboraplasovska wants to merge 7 commits into
Open
✨RUM-16635 Add wildcard host pattern matching to WebView event bridge#4703barboraplasovska wants to merge 7 commits into
barboraplasovska wants to merge 7 commits into
Conversation
|
All contributors have signed the CLA ✍️ ✅ |
🎉 All green!🧪 All tests passed 🎯 Code Coverage (details) 🔗 Commit SHA: 7a9cd64 | Docs | Datadog PR Page | Give us feedback! |
Bundles Sizes Evolution
|
Author
|
I have read the CLA Document and I hereby sign the CLA |
5 tasks
3884f98 to
6a7e913
Compare
…a separate method
6a7e913 to
5f724c9
Compare
mormubis
requested changes
Jun 4, 2026
mormubis
approved these changes
Jun 5, 2026
Co-authored-by: Adrian de la Rosa <adrian.delarosa@datadoghq.com>
gogusarov
reviewed
Jun 5, 2026
| bridge | ||
| .getAllowedWebViewHosts() | ||
| .some((allowedHost) => currentHost === allowedHost || currentHost.endsWith(`.${allowedHost}`)) | ||
| bridge?.getAllowedWebViewHosts().some((entry) => { |
Contributor
There was a problem hiding this comment.
suggestion
we currently have a couple of duplicating checks both inside some iterator and inside matchesWildcardPattern function. I suggest to combine them into one function and use early returns for readability
export function canUseEventBridge(currentHost = globalObject.location?.hostname): boolean {
const bridge = getEventBridge()
return bridge?.getAllowedWebViewHosts().some((entry) =>
matchesHostEntry(currentHost, entry)) ?? false
}
export function matchesHostEntry(host: string, entry: string): boolean
{
if (!entry.includes('*')) {
return host === entry || host.endsWith(`.${entry}`)
}
const parts = entry.split('*')
if (parts.length !== 2) {
display.error(`Invalid WebView host pattern "${entry}": only one
wildcard (*) is supported.`)
return false
}
const [prefix, suffix] = parts
return host.length >= prefix.length + suffix.length &&
host.startsWith(prefix) && host.endsWith(suffix)
}
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Part of RUM-15826. iOS SDK counterpart DataDog/dd-sdk-ios#2963.
Changes
Adds a new optional
getAllowedWebViewHostPatterns?()method to theDatadogEventBridgeinterface. When present,canUseEventBridge()uses wildcard pattern matching via plain string operations instead of the legacy exact + subdomain-suffix path.Invalid patterns (more than one
*) produce adisplay.errorconsole warning so customers see an actionable signal. Old Browser SDK versions receiving wildcard entries from a new mobile SDK will silently ignore them (literal match fails) while plain host entries continue to bridge normally.Test instructions
CI should pass.
Checklist