Skip to content
Open
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: 4 additions & 1 deletion hlx_statics/scripts/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -848,8 +848,11 @@ function loadPrism(document) {
const pre = env.element.closest('pre');
const sessionId = pre?.getAttribute('data-playground-session-id');
const playgroundMode = pre?.getAttribute('data-playground-mode');

const playgroundExecutionMode = pre?.getAttribute('data-playground-execution-mode');
const playgroundURL = pre?.getAttribute('data-playground-url');
const playgroundURL = isStageEnvironment(window.location.host) || isLocalHostEnvironment(window.location.host)
Copy link
Collaborator

@melissag-ensemble melissag-ensemble Mar 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To handle .page urls, please modify the env checks so you can use it as a util:

export function isStageEnvironment(host, includeAemHosts = false) {
  return host.indexOf('stage.adobe.io') >= 0
    || host.indexOf('developer-stage') >= 0
    || (includeAemHosts && host.indexOf('.page') >= 0 && host.indexOf('--adp-devsite-stage--') >= 0);
}

export function isDevEnvironment(host, includeAemHosts = false) {
  return host.indexOf('developer-dev') >= 0
    || (includeAemHosts && host.indexOf('.page') >= 0 && host.indexOf('--adp-devsite--') < 0);
}

export function isProdEnvironment(host, includeAemHosts = false) {
  return host.indexOf('developer.adobe.com') >= 0
    || (includeAemHosts && host.indexOf('.live') >= 0);
}

Then update your logic to:

Suggested change
const playgroundURL = isStageEnvironment(window.location.host) || isLocalHostEnvironment(window.location.host)
const playgroundURL = isStageEnvironment(window.location.host, true) || isLocalHostEnvironment(window.location.host)

For details, please see slack discussion: https://adobeio.slack.com/archives/C06M1C7UBV3/p1772728512877719?thread_ts=1772608055.424379&cid=C06M1C7UBV3

Copy link

@timkim timkim Mar 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since there are situations where we want to know if we're on developer-stage.adobe.com, developer.adobe.com, localhost, or on a .page or .live url, I think the above should handle our needs.

? (pre?.getAttribute('data-playground-url-stage') || pre?.getAttribute('data-playground-url'))
: pre?.getAttribute('data-playground-url');
if (!sessionId || !playgroundMode || !playgroundExecutionMode || !playgroundURL) return null;
const btn = createTag('button', { class: 'try-code-button' });
btn.textContent = 'Try in playground';
Expand Down
Loading