@@ -451,18 +451,25 @@ public function test_replacement_without_scheme() {
451451 }
452452
453453 /**
454- * Regression test: triple-slash URLs (///host/path ) must be normalized to
455- * http(s)://host/path before CDN embedding — never produce https:///host/path.
454+ * Regression test: build_url( ) must normalize protocol-relative and
455+ * triple-slash URLs to http(s)://host/path — never produce https:///host/path.
456456 */
457- public function test_replacement_triple_slash_url () {
458- $ content = '<div class="codeinwp-container">
459- <img src="///www.example.org/wp-content/uploads/2018/05/brands.png">
460- </div> ' ;
461- $ replaced_content = Optml_Manager::instance ()->replace_content ( $ content );
462-
463- $ this ->assertStringContainsString ( 'i.optimole.com ' , $ replaced_content );
464- $ this ->assertStringNotContainsString ( ':/// ' , $ replaced_content );
465- $ this ->assertStringContainsString ( 'http://www.example.org ' , $ replaced_content );
457+ public function test_build_url_normalizes_triple_slash () {
458+ // Protocol-relative URL (//host/path) should be normalized correctly.
459+ $ url = '//www.example.org/wp-content/uploads/2018/05/brands.png ' ;
460+ $ result = Optml_Url_Replacer::instance ()->build_url ( $ url );
461+
462+ $ this ->assertStringContainsString ( 'i.optimole.com ' , $ result );
463+ $ this ->assertStringNotContainsString ( ':/// ' , $ result );
464+ $ this ->assertStringContainsString ( 'http://www.example.org ' , $ result );
465+
466+ // Triple-slash URL (///host/path) should also be normalized correctly.
467+ $ url = '///www.example.org/wp-content/uploads/2018/05/brands.png ' ;
468+ $ result = Optml_Url_Replacer::instance ()->build_url ( $ url );
469+
470+ $ this ->assertStringContainsString ( 'i.optimole.com ' , $ result );
471+ $ this ->assertStringNotContainsString ( ':/// ' , $ result );
472+ $ this ->assertStringContainsString ( 'http://www.example.org ' , $ result );
466473 }
467474
468475 public function test_non_allowed_extensions () {
0 commit comments