fix(client): return an empty string for empty sections

This commit is contained in:
Valeriy S
2019-02-18 12:43:09 +03:00
committed by Stuart Taylor
parent cd501ee4c5
commit 6d5e3865e7
3 changed files with 15 additions and 10 deletions

View File

@@ -9,17 +9,11 @@ const propTypes = {
section: PropTypes.string
};
function emptyInstruction(instructions) {
return /^<section\s+id\s*=\s*("|')instructions\1\s*>\s*<\/section>$/.test(
instructions
);
}
function ChallengeDescription({ description, instructions, section }) {
return (
<div className={`challenge-instructions ${section}`}>
<div dangerouslySetInnerHTML={{ __html: description }} />
{!emptyInstruction(instructions) && (
{instructions && (
<Fragment>
<hr />
<div dangerouslySetInnerHTML={{ __html: instructions }} />