Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CORL-3177]: update to grab the ORIGIN from the count.js script for #4638

Merged
merged 1 commit into from
Jul 2, 2024
Merged
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
7 changes: 5 additions & 2 deletions client/src/core/client/count/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { COUNT_SELECTOR } from "coral-framework/constants";
import detectCountScript from "coral-framework/helpers/detectCountScript";
import getCurrentScriptOrigin from "coral-framework/helpers/getCurrentScriptOrigin";
import resolveStoryURL from "coral-framework/helpers/resolveStoryURL";
import jsonp from "coral-framework/utils/jsonp";

Expand All @@ -23,7 +22,11 @@ interface DetectAndInjectArgs {

/** Detects count elements and use jsonp to inject the counts. */
function detectAndInject(opts: DetectAndInjectArgs = {}) {
const ORIGIN = getCurrentScriptOrigin();
// Get ORIGIN from the count.js script that we know will be on the page.
const ORIGIN = document
.querySelector(".coral-script")
?.getAttribute("src")
?.split("/assets")[0];
const STORY_URL = resolveStoryURL(window);

/** A map of references pointing to the count query arguments */
Expand Down
Loading