From 85f2c005cdf5c3cbf74b9ab187011337a8e7306a Mon Sep 17 00:00:00 2001 From: Berkeley Martinez Date: Mon, 5 Oct 2015 20:18:52 -0700 Subject: [PATCH] fix shareable challenges solution undefined During challenges when a user tries to navigate to a challenge and hits the name redirect, the solution is filled with undefined starting the user with an empty box. This PR fixes the issue by ignoring the solution param if it is empty --- server/boot/challenge.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/server/boot/challenge.js b/server/boot/challenge.js index 6a056b705d..dade963b1e 100644 --- a/server/boot/challenge.js +++ b/server/boot/challenge.js @@ -267,12 +267,13 @@ module.exports = function(app) { } if (dasherize(challenge.name) !== origChallengeName) { - return Observable.just( - '/challenges/' + - dasherize(challenge.name) + - '?solution=' + - encodeURIComponent(solutionCode) - ); + let redirectUrl = `/challenges/${dasherize(challenge.name)}`; + + if (solutionCode) { + redirectUrl += `?solution=${encodeURIComponent(solutionCode)}`; + } + + return Observable.just(redirectUrl); } // save user does nothing if user does not exist