Skip to content

Fix academy test launcher#194

Closed
CodexRaunak wants to merge 1 commit into
layer5io:masterfrom
CodexRaunak:fix-serialization
Closed

Fix academy test launcher#194
CodexRaunak wants to merge 1 commit into
layer5io:masterfrom
CodexRaunak:fix-serialization

Conversation

@CodexRaunak
Copy link
Copy Markdown
Contributor

Notes for Reviewers

  • This fixes the Academy test launcher regression in layouts/test/single.html. The emitted script was producing invalid JS string values.

Examples:

  • before, the launcher could emit build='"production"' instead of build="production", so build === "production" evaluated false and the redirect never ran

    • before, a page at /academy/certifications//certified-meshery-contributor/meshery-extensibility/test/ could derive curriculaRoot as /academy/.../meshery-extensibility/test, then redirect to /academy/.../
      meshery-extensibility/test/test?...
    • after this patch, the same page derives curriculaRoot as /academy/.../meshery-extensibility, so the redirect becomes /academy/.../meshery-extensibility/test?.

    The patch uses jsonify | safeJS for launcher literals and trims the trailing /test when deriving the parent redirect base.

Signed commits

  • Yes, I signed my commits.

Signed-off-by: Raunak Madan <madanraunak24@gmail.com>
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 20, 2026

PR Preview Action v1.6.3
Preview removed because the pull request was closed.
2026-05-21 22:10 UTC

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the calculation of curriculaRoot in layouts/test/single.html and updates several script variables to use safeJS. A review comment suggests using a regular expression instead of strings.TrimSuffix to more reliably derive the curriculaRoot path.

Comment thread layouts/test/single.html

{{ $test := partial "test/single.html" . }}
{{ $tesAbsPath := .RelPermalink }}
{{ $curriculaRoot := .RelPermalink | strings.TrimSuffix "/" | strings.TrimSuffix "/test" }}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The current implementation to derive curriculaRoot using strings.TrimSuffix is a bit fragile. It could lead to incorrect paths if a directory name happens to end with "test" but is not exactly "test" (e.g., /some/path/latest-test/).

A more robust approach would be to use a regular expression to ensure you're removing the /test segment only when it appears at the very end of the path.

Consider this alternative:

{{ $curriculaRoot := .RelPermalink | replaceRE "/test/?$" "" }}

This uses replaceRE to remove /test or /test/ from the end of the .RelPermalink, which is safer and more explicit about the intent.

Suggested change
{{ $curriculaRoot := .RelPermalink | strings.TrimSuffix "/" | strings.TrimSuffix "/test" }}
{{ $curriculaRoot := .RelPermalink | replaceRE "/test/?$" "" }}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant