Closed (fixed)
Project:
Marketo JS Forms Integration
Version:
3.0.2
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Reporter:
Created:
20 Dec 2024 at 10:07 UTC
Updated:
4 Aug 2026 at 07:16 UTC
Jump to comment: Most recent
Specifying the host gives the following output in the DOM
<script src="////id.mktoweb.com/js/forms2/js/forms2.min.js"></script>
This is caused by the adding "//" prefix twice which is unnecessary. Although browsers seem to workaround this faulty syntax, this is not ideal and was actually picked by broken link checker.
Add host to config, look at the actual generated DOM>
Will submit a patch later today.
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
davisa commentedComment #4
davisa commentedRemoving the duplicate "//" lead to Drupal's domain being prefixed which is quite strange, and probably is the reason why quadruple //// is used instead as workaround.
Comment #5
davisa commentedI found the root cause.
MktoForms2.loadForm(host, munchkinId, formId);The loadForm() expects a host with a "//" preffix as can be seen @ https://developers.marketo.com/rest-api/assets/forms/examples/
Since the backend strips out the "//", it's loaded without "//" preffix.
However, `marketo_forms.module` applies it twice and in some odd way makes the form load successfully. However, that is just a workaround that just works due to more broader browser support for invalid URL formatting. I've created a fix for this, merge request: https://git.drupalcode.org/project/marketo_forms/-/merge_requests/8
Comment #6
levmyshkinThanks for the report and for chasing down the root cause, davisa — comment #5 is exactly right. MktoForms2.loadForm() wants the host with the "//" prefix, and the module was applying it twice.
Fixed on both branches:
3.0.x — commit 7efac19, released in 3.0.3
4.0.x — commit e191549, released in 4.1.0
The fix normalises at the opposite end from MR !8. $host keeps its "//" prefix, so drupalSettings.marketoForms.host stays in the shape loadForm() expects and js/marketo-forms.js needs no change; the duplicate prefix is dropped from the library's JS key instead:
which gives
src="//app-xxx.marketo.com/js/forms2/js/forms2.min.js". Same two slashes, just removed at the other end of the pipeline — both approaches are correct, and I picked this one because it leaves the JS untouched.Two notes on MR !8, so it's clear why it wasn't merged as-is:
1. It patches marketo_forms.module, but since the Drupal 11 OOP hook conversion (fdb8a82) that file only contains #[LegacyHook] wrappers. The implementation that actually runs is Drupal\marketo_forms\Hook\MarketoFormsHooks::libraryInfoBuild(), so the MR's PHP hunk has no effect on D11.
2. Applied on top of the current code it would reintroduce the bug in mirror image: $host would lose its prefix while the JS adds one back, leaving drupalSettings.marketoForms.host and the script src disagreeing.
Fixed in the same commit: the library's license array was missing the "url" key, which raised an "Undefined array key" warning from JsCollectionOptimizerLazy on every page that embedded a form.
There is a regression test now, so this cannot come back silently — tests/src/Kernel/MarketoFormsLibraryTest.php asserts the script URL carries exactly two leading slashes, and MarketoFormsBlockTest::testForms2ScriptIsAttached() checks the rendered markup. Both run in GitLab CI.
Marking fixed. Credit to davisa for the report, the diagnosis and the MR.
Comment #8
levmyshkin