diff --git a/src/ConvertKit_API_Traits.php b/src/ConvertKit_API_Traits.php index 471c1b8..5267f5d 100644 --- a/src/ConvertKit_API_Traits.php +++ b/src/ConvertKit_API_Traits.php @@ -2682,6 +2682,11 @@ public function convert_relative_to_absolute_urls(\DOMNodeList $elements, string continue; } + // Skip if the attribute's value is an anchor. + if (strpos($element->getAttribute($attribute), '#') !== false) { + continue; + } + // Remove element if it's rocket-loader.min.js. Including it prevents landing page redirects from working. if (strpos($element->getAttribute($attribute), 'rocket-loader.min.js') !== false) { if ($element->parentNode instanceof \DOMNode) { diff --git a/tests/ConvertKitMethodsTest.php b/tests/ConvertKitMethodsTest.php index 5152d1c..2373c03 100644 --- a/tests/ConvertKitMethodsTest.php +++ b/tests/ConvertKitMethodsTest.php @@ -47,6 +47,7 @@ public function testConvertRelativeToAbsoluteUrls()
Test + Anchor
@@ -112,6 +113,12 @@ public function testConvertRelativeToAbsoluteUrls()
'',
$output
);
+
+ // Assert string contains expected HTML elements that should not be modified.
+ $this->assertStringContainsString(
+ 'Anchor',
+ $output
+ );
}
/**