-
Notifications
You must be signed in to change notification settings - Fork 31
Revert "fix: resolve incorrect URLs for pre-quiz tests missing /academy prefix" #195
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -349,9 +349,9 @@ <h1>{{ $title }}</h1> | |||||
| {{ $tesAbsPath := .RelPermalink }} | ||||||
|
|
||||||
| <script> | ||||||
| const testId = {{ $test.id | jsonify }}; | ||||||
| const testId = {{$test.id}}; | ||||||
| const testAbsPath = "{{$tesAbsPath}}"; | ||||||
| const build = {{ $build | jsonify }}; | ||||||
| const build = {{$build}}; | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The
Suggested change
|
||||||
|
|
||||||
|
|
||||||
| // Event Listeners | ||||||
|
|
@@ -377,7 +377,7 @@ <h1>{{ $title }}</h1> | |||||
| window.addEventListener("academyContextReady", () => { | ||||||
| if (isProdBuild && window.academyContext?.RegistrationData?.id) { | ||||||
| // redirect to test page | ||||||
| const curriculaRoot = {{ .RelPermalink | strings.TrimSuffix "/" | jsonify }}; | ||||||
| const curriculaRoot = window.location.pathname.split("/").slice(0, 5).join("/"); | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using
Suggested change
|
||||||
| window.location.replace(`${curriculaRoot}/test?id=${testId}®istration_id=${window.academyContext?.RegistrationData?.id}&test_abs_path=${testAbsPath}`); | ||||||
| return; | ||||||
| } | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing the
jsonifyfilter will cause a JavaScript syntax error because the value (which is a string) will be rendered without surrounding quotes (e.g.,const testId = some-id;). Usingjsonifyis the idiomatic way to safely pass Hugo variables to JavaScript as it handles both quoting and escaping.