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
This commit is contained in:
Berkeley Martinez
2015-10-05 20:18:52 -07:00
parent bf4ccab586
commit 85f2c005cd

View File

@ -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