MCPcopy Create free account
hub / github.com/codecombat/codecombat / executeHackstackRedirect

Method executeHackstackRedirect

app/views/play/CampaignView.js:2622–2644  ·  view source on GitHub ↗

* Execute HackStack redirect after all loading is complete * @param {Object} redirectInfo - Redirect information from checkHackstackRedirect

(redirectInfo)

Source from the content-addressed store, hash-verified

2620 * @param {Object} redirectInfo - Redirect information from checkHackstackRedirect
2621 */
2622 executeHackstackRedirect (redirectInfo) {
2623 if (redirectInfo) {
2624 try {
2625 // Use URL API to properly merge query parameters and hash
2626 const destUrl = new URL(redirectInfo.dest, window.location.origin)
2627 const currentUrl = new URL(window.location.href)
2628 // Merge query parameters
2629 currentUrl.searchParams.forEach((value, key) => {
2630 destUrl.searchParams.set(key, value)
2631 })
2632 // Preserve hash fragment
2633 if (currentUrl.hash) {
2634 destUrl.hash = currentUrl.hash
2635 }
2636 application.router.navigate(destUrl.pathname + destUrl.search + destUrl.hash, { trigger: true, replace: true })
2637 } catch (e) {
2638 // Fallback to simple concatenation if URL API fails
2639 const query = location.search || ''
2640 const hash = location.hash || ''
2641 application.router.navigate(`${redirectInfo.dest}${query}${hash}`, { trigger: true, replace: true })
2642 }
2643 }
2644 }
2645
2646 isJuniorCampaign () {
2647 const campaignObj = this.campaign || (typeof this.terrain === 'object' ? this.terrain : null)

Callers 2

constructorMethod · 0.95
onLoadedMethod · 0.95

Calls 2

navigateMethod · 0.80
setMethod · 0.45

Tested by

no test coverage detected