fix(client): show source code link when localhost exists (#54087)

This commit is contained in:
Shaun Hamilton 2024-04-01 18:28:27 +02:00 committed by GitHub
parent 522977ec1c
commit f0ebd30f5c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,6 +1,6 @@
import type { CompletedChallenge } from '../redux/prop-types';
import { challengeTypes } from '../../../shared/config/challenge-types';
import { maybeUrlRE } from '.';
import { hasProtocolRE } from '.';
type DisplayType =
| 'none'
@ -26,7 +26,7 @@ export const getSolutionDisplayType = ({
if (!solution) return 'none';
// Some of the user records still have JavaScript project solutions stored as
// solution strings
if (!maybeUrlRE.test(solution)) return 'showUserCode';
if (maybeUrlRE.test(githubLink ?? '')) return 'showProjectAndGithubLinks';
if (!hasProtocolRE.test(solution)) return 'showUserCode';
if (hasProtocolRE.test(githubLink ?? '')) return 'showProjectAndGithubLinks';
return 'showProjectLink';
};