Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/ConvertKit_API_Traits.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
7 changes: 7 additions & 0 deletions tests/ConvertKitMethodsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public function testConvertRelativeToAbsoluteUrls()
</head>
<body>
<a href="/test">Test</a>
<a href="#anchor">Anchor</a>
<img src="/test.jpg" />
<script type="text/javascript" src="/test.js"></script>
<form action="/test">Test</form>
Expand Down Expand Up @@ -112,6 +113,12 @@ public function testConvertRelativeToAbsoluteUrls()
'<form action="' . $url_scheme_host_only . '/test">Test</form>',
$output
);

// Assert string contains expected HTML elements that should not be modified.
$this->assertStringContainsString(
'<a href="#anchor">Anchor</a>',
$output
);
}

/**
Expand Down