@@ -21,7 +21,6 @@ pub struct HtmlProcessorConfig {
2121 pub origin_host : String ,
2222 pub request_host : String ,
2323 pub request_scheme : String ,
24- pub enable_prebid : bool ,
2524 pub integrations : IntegrationRegistry ,
2625 pub nextjs_enabled : bool ,
2726 pub nextjs_attributes : Vec < String > ,
@@ -47,7 +46,6 @@ impl HtmlProcessorConfig {
4746 origin_host : origin_host. to_string ( ) ,
4847 request_host : request_host. to_string ( ) ,
4948 request_scheme : request_scheme. to_string ( ) ,
50- enable_prebid : settings. prebid . auto_configure ,
5149 integrations : integrations. clone ( ) ,
5250 nextjs_enabled : settings. publisher . nextjs . enabled ,
5351 nextjs_attributes : settings. publisher . nextjs . rewrite_attributes . clone ( ) ,
@@ -134,16 +132,6 @@ pub fn create_html_processor(config: HtmlProcessorConfig) -> impl StreamProcesso
134132 let integration_registry = config. integrations . clone ( ) ;
135133 let script_rewriters = integration_registry. script_rewriters ( ) ;
136134
137- fn is_prebid_script_url ( url : & str ) -> bool {
138- let lower = url. to_ascii_lowercase ( ) ;
139- let without_query = lower. split ( '?' ) . next ( ) . unwrap_or ( "" ) ;
140- let filename = without_query. rsplit ( '/' ) . next ( ) . unwrap_or ( "" ) ;
141- matches ! (
142- filename,
143- "prebid.js" | "prebid.min.js" | "prebidjs.js" | "prebidjs.min.js"
144- )
145- }
146-
147135 let mut element_content_handlers = vec ! [
148136 element!( "head" , {
149137 let injected_tsjs = injected_tsjs. clone( ) ;
@@ -168,20 +156,15 @@ pub fn create_html_processor(config: HtmlProcessorConfig) -> impl StreamProcesso
168156 } ) ,
169157 element!( "[href]" , {
170158 let patterns = patterns. clone( ) ;
171- let rewrite_prebid = config. enable_prebid;
172159 let integrations = integration_registry. clone( ) ;
173160 move |el| {
174161 if let Some ( mut href) = el. get_attribute( "href" ) {
175162 let original_href = href. clone( ) ;
176- if rewrite_prebid && is_prebid_script_url( & href) {
177- href = tsjs:: ext_script_src( ) ;
178- } else {
179- let new_href = href
180- . replace( & patterns. https_origin( ) , & patterns. replacement_url( ) )
181- . replace( & patterns. http_origin( ) , & patterns. replacement_url( ) ) ;
182- if new_href != href {
183- href = new_href;
184- }
163+ let new_href = href
164+ . replace( & patterns. https_origin( ) , & patterns. replacement_url( ) )
165+ . replace( & patterns. http_origin( ) , & patterns. replacement_url( ) ) ;
166+ if new_href != href {
167+ href = new_href;
185168 }
186169
187170 if let Some ( integration_href) = integrations. rewrite_attribute(
@@ -206,20 +189,15 @@ pub fn create_html_processor(config: HtmlProcessorConfig) -> impl StreamProcesso
206189 } ) ,
207190 element!( "[src]" , {
208191 let patterns = patterns. clone( ) ;
209- let rewrite_prebid = config. enable_prebid;
210192 let integrations = integration_registry. clone( ) ;
211193 move |el| {
212194 if let Some ( mut src) = el. get_attribute( "src" ) {
213195 let original_src = src. clone( ) ;
214- if rewrite_prebid && is_prebid_script_url( & src) {
215- src = tsjs:: ext_script_src( ) ;
216- } else {
217- let new_src = src
218- . replace( & patterns. https_origin( ) , & patterns. replacement_url( ) )
219- . replace( & patterns. http_origin( ) , & patterns. replacement_url( ) ) ;
220- if new_src != src {
221- src = new_src;
222- }
196+ let new_src = src
197+ . replace( & patterns. https_origin( ) , & patterns. replacement_url( ) )
198+ . replace( & patterns. http_origin( ) , & patterns. replacement_url( ) ) ;
199+ if new_src != src {
200+ src = new_src;
223201 }
224202
225203 if let Some ( integration_src) = integrations. rewrite_attribute(
@@ -437,7 +415,9 @@ pub fn create_html_processor(config: HtmlProcessorConfig) -> impl StreamProcesso
437415mod tests {
438416 use super :: * ;
439417 use crate :: streaming_processor:: { Compression , PipelineConfig , StreamingPipeline } ;
418+ use crate :: test_support:: tests:: create_test_settings;
440419 use crate :: tsjs;
420+ use serde_json:: json;
441421 use std:: io:: Cursor ;
442422
443423 const MOCK_TESTLIGHT_SRC : & str = "https://mock.testassets/testlight.js" ;
@@ -460,62 +440,24 @@ mod tests {
460440 origin_host : "origin.example.com" . to_string ( ) ,
461441 request_host : "test.example.com" . to_string ( ) ,
462442 request_scheme : "https" . to_string ( ) ,
463- enable_prebid : false ,
464443 integrations : IntegrationRegistry :: default ( ) ,
465444 nextjs_enabled : false ,
466445 nextjs_attributes : vec ! [ "href" . to_string( ) , "link" . to_string( ) , "url" . to_string( ) ] ,
467446 integration_assets : Vec :: new ( ) ,
468447 }
469448 }
470449
471- #[ test]
472- fn test_injects_tsjs_script_and_rewrites_prebid_refs ( ) {
473- let html = r#"<html><head>
474- <script src="/js/prebid.min.js"></script>
475- <link rel="preload" as="script" href="https://cdn.prebid.org/prebid.js" />
476- </head><body></body></html>"# ;
477-
478- let mut config = create_test_config ( ) ;
479- config. enable_prebid = true ; // enable rewriting of Prebid URLs
480- let processor = create_html_processor ( config) ;
481- let pipeline_config = PipelineConfig {
482- input_compression : Compression :: None ,
483- output_compression : Compression :: None ,
484- chunk_size : 8192 ,
485- } ;
486- let mut pipeline = StreamingPipeline :: new ( pipeline_config, processor) ;
487-
488- let mut output = Vec :: new ( ) ;
489- let result = pipeline. process ( Cursor :: new ( html. as_bytes ( ) ) , & mut output) ;
490- assert ! ( result. is_ok( ) ) ;
491- let processed = String :: from_utf8_lossy ( & output) ;
492- assert ! ( processed. contains( "/static/tsjs=tsjs-core.min.js" ) ) ;
493- // Prebid references are rewritten to our extension when auto-configure is on
494- assert ! ( processed. contains( "/static/tsjs=tsjs-ext.min.js" ) ) ;
495- }
496-
497- #[ test]
498- fn test_injects_tsjs_script_and_rewrites_prebid_with_query_string ( ) {
499- let html = r#"<html><head>
500- <script src="/wp-content/plugins/prebidjs/js/prebidjs.min.js?v=1.2.3"></script>
501- </head><body></body></html>"# ;
502-
503- let mut config = create_test_config ( ) ;
504- config. enable_prebid = true ; // enable rewriting of Prebid URLs
505- let processor = create_html_processor ( config) ;
506- let pipeline_config = PipelineConfig {
507- input_compression : Compression :: None ,
508- output_compression : Compression :: None ,
509- chunk_size : 8192 ,
510- } ;
511- let mut pipeline = StreamingPipeline :: new ( pipeline_config, processor) ;
512-
513- let mut output = Vec :: new ( ) ;
514- let result = pipeline. process ( Cursor :: new ( html. as_bytes ( ) ) , & mut output) ;
515- assert ! ( result. is_ok( ) ) ;
516- let processed = String :: from_utf8_lossy ( & output) ;
517- assert ! ( processed. contains( "/static/tsjs=tsjs-core.min.js" ) ) ;
518- assert ! ( processed. contains( "/static/tsjs=tsjs-ext.min.js" ) ) ;
450+ fn config_from_settings (
451+ settings : & Settings ,
452+ registry : & IntegrationRegistry ,
453+ ) -> HtmlProcessorConfig {
454+ HtmlProcessorConfig :: from_settings (
455+ settings,
456+ registry,
457+ "origin.example.com" ,
458+ "test.example.com" ,
459+ "https" ,
460+ )
519461 }
520462
521463 #[ test]
@@ -525,8 +467,23 @@ mod tests {
525467 <link rel="preload" as="script" href="https://cdn.prebid.org/prebid.js" />
526468 </head><body></body></html>"# ;
527469
528- let mut config = create_test_config ( ) ;
529- config. enable_prebid = false ; // No longer affects tsjs injection
470+ let mut settings = create_test_settings ( ) ;
471+ settings
472+ . integrations
473+ . insert_config (
474+ "prebid" ,
475+ & json ! ( {
476+ "enabled" : true ,
477+ "server_url" : "https://test-prebid.com/openrtb2/auction" ,
478+ "timeout_ms" : 1000 ,
479+ "bidders" : [ "mocktioneer" ] ,
480+ "auto_configure" : false ,
481+ "debug" : false
482+ } ) ,
483+ )
484+ . expect ( "should update prebid config" ) ;
485+ let registry = IntegrationRegistry :: new ( & settings) ;
486+ let config = config_from_settings ( & settings, & registry) ;
530487 let processor = create_html_processor ( config) ;
531488 let pipeline_config = PipelineConfig {
532489 input_compression : Compression :: None ,
@@ -709,8 +666,6 @@ mod tests {
709666
710667 #[ test]
711668 fn test_html_processor_config_from_settings ( ) {
712- use crate :: test_support:: tests:: create_test_settings;
713-
714669 let settings = create_test_settings ( ) ;
715670 let registry = IntegrationRegistry :: new ( & settings) ;
716671 let config = HtmlProcessorConfig :: from_settings (
@@ -724,7 +679,6 @@ mod tests {
724679 assert_eq ! ( config. origin_host, "origin.test-publisher.com" ) ;
725680 assert_eq ! ( config. request_host, "proxy.example.com" ) ;
726681 assert_eq ! ( config. request_scheme, "https" ) ;
727- assert ! ( config. enable_prebid) ; // Uses default true
728682 assert ! (
729683 !config. nextjs_enabled,
730684 "Next.js rewrites should default to disabled"
@@ -755,7 +709,6 @@ mod tests {
755709 let mut config = create_test_config ( ) ;
756710 config. origin_host = "www.test-publisher.com" . to_string ( ) ; // Match what's in the HTML
757711 config. request_host = "test-publisher-ts.edgecompute.app" . to_string ( ) ;
758- config. enable_prebid = true ; // Enable Prebid auto-configuration
759712
760713 let processor = create_html_processor ( config) ;
761714 let pipeline_config = PipelineConfig {
@@ -883,7 +836,6 @@ mod tests {
883836 let mut config = create_test_config ( ) ;
884837 config. origin_host = "www.test-publisher.com" . to_string ( ) ; // Match what's in the HTML
885838 config. request_host = "test-publisher-ts.edgecompute.app" . to_string ( ) ;
886- config. enable_prebid = true ;
887839
888840 let processor = create_html_processor ( config) ;
889841 let pipeline_config = PipelineConfig {
@@ -1006,7 +958,6 @@ mod tests {
1006958 let mut config = create_test_config ( ) ;
1007959 config. origin_host = "www.test-publisher.com" . to_string ( ) ; // Match what's in the HTML
1008960 config. request_host = "test-publisher-ts.edgecompute.app" . to_string ( ) ;
1009- config. enable_prebid = true ;
1010961
1011962 let processor = create_html_processor ( config) ;
1012963 let pipeline_config = PipelineConfig {
0 commit comments