File tree Expand file tree Collapse file tree
crates/trusted-server-core/src/integrations Expand file tree Collapse file tree Original file line number Diff line number Diff line change 5252//! automatically rewrite `DataDome` script URLs in HTML responses:
5353//!
5454//! - `<script src="https://js.datadome.co/tags.js">` becomes
55- //! `<script src="https://publisher.com /integrations/datadome/tags.js">`
55+ //! `<script src="/integrations/datadome/tags.js">`
5656//! - Handles both `src` and `href` attributes (for preload/prefetch links)
5757
5858use std:: sync:: { Arc , LazyLock } ;
@@ -815,6 +815,10 @@ impl IntegrationAttributeRewriter for DataDomeIntegration {
815815
816816 let path = Self :: extract_datadome_path ( attr_value) ;
817817 // Root-relative so the browser resolves it against the page host.
818+ // Note: a page-level `<base href>` participates in this resolution, so
819+ // on pages that set an external base URL these resolve against that base
820+ // rather than the address-bar origin — an accepted tradeoff, matching
821+ // GTM/Didomi/Testlight which are also relative.
818822 let new_url = format ! ( "/integrations/datadome{path}" ) ;
819823
820824 log:: info!(
Original file line number Diff line number Diff line change @@ -443,6 +443,10 @@ impl IntegrationAttributeRewriter for GptIntegration {
443443
444444 if Self :: is_gpt_script_url ( attr_value) {
445445 // Root-relative so the browser resolves it against the page host.
446+ // Note: a page-level `<base href>` participates in this resolution,
447+ // so on pages that set an external base URL these resolve against
448+ // that base rather than the address-bar origin — an accepted
449+ // tradeoff, matching GTM/Didomi/Testlight which are also relative.
446450 AttributeRewriteAction :: replace ( "/integrations/gpt/script" . to_string ( ) )
447451 } else {
448452 AttributeRewriteAction :: keep ( )
Original file line number Diff line number Diff line change @@ -420,6 +420,10 @@ impl IntegrationAttributeRewriter for LockrIntegration {
420420
421421 if self . is_lockr_sdk_url ( attr_value) {
422422 // Root-relative so the browser resolves it against the page host.
423+ // Note: a page-level `<base href>` participates in this resolution,
424+ // so on pages that set an external base URL these resolve against
425+ // that base rather than the address-bar origin — an accepted
426+ // tradeoff, matching GTM/Didomi/Testlight which are also relative.
423427 let replacement = "/integrations/lockr/sdk" . to_string ( ) ;
424428 log:: debug!( "Rewriting Lockr SDK URL to {}" , replacement) ;
425429 AttributeRewriteAction :: Replace ( replacement)
Original file line number Diff line number Diff line change @@ -434,6 +434,10 @@ impl IntegrationAttributeRewriter for PermutiveIntegration {
434434 if self . is_permutive_sdk_url ( attr_value) {
435435 // Rewrite to first-party SDK endpoint.
436436 // Root-relative so the browser resolves it against the page host.
437+ // Note: a page-level `<base href>` participates in this resolution,
438+ // so on pages that set an external base URL these resolve against
439+ // that base rather than the address-bar origin — an accepted
440+ // tradeoff, matching GTM/Didomi/Testlight which are also relative.
437441 AttributeRewriteAction :: replace ( "/integrations/permutive/sdk" . to_string ( ) )
438442 } else {
439443 AttributeRewriteAction :: keep ( )
Original file line number Diff line number Diff line change @@ -355,6 +355,10 @@ impl SourcepointIntegration {
355355 . unwrap_or_default ( ) ;
356356
357357 // Root-relative so the browser resolves it against the page host.
358+ // Note: a page-level `<base href>` participates in this resolution, so
359+ // on pages that set an external base URL these resolve against that base
360+ // rather than the address-bar origin — an accepted tradeoff, matching
361+ // GTM/Didomi/Testlight which are also relative.
358362 Some ( format ! ( "{SOURCEPOINT_CDN_PREFIX}{path}{query}" ) )
359363 }
360364
You can’t perform that action at this time.
0 commit comments