Merge branch 'master' into feature/misuse-of-findIndex
This commit is contained in:
@@ -11,6 +11,12 @@ const sanitizeOptions = {
|
|||||||
|
|
||||||
function Markdown({ source }) {
|
function Markdown({ source }) {
|
||||||
const sanitized = sanitize(source, sanitizeOptions)
|
const sanitized = sanitize(source, sanitizeOptions)
|
||||||
|
|
||||||
|
// sometimes the sanitizer returns "undefined" as a string
|
||||||
|
if(!source || !sanitized || sanitized === "undefined") {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
return <Remarkable
|
return <Remarkable
|
||||||
options={{html: true, typographer: true, linkify: true, linkTarget: "_blank"}}
|
options={{html: true, typographer: true, linkify: true, linkTarget: "_blank"}}
|
||||||
source={sanitized}
|
source={sanitized}
|
||||||
|
|||||||
37
test/bugs/3279-empty-markdown-source.js
Normal file
37
test/bugs/3279-empty-markdown-source.js
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
/* eslint-env mocha */
|
||||||
|
import React from "react"
|
||||||
|
import expect from "expect"
|
||||||
|
import { render } from "enzyme"
|
||||||
|
import Markdown from "components/providers/markdown"
|
||||||
|
|
||||||
|
describe("UI-3279: Empty Markdown inputs causing bare `undefined` in output", function(){
|
||||||
|
it("should return no text for `null` as source input", function(){
|
||||||
|
let props = {
|
||||||
|
source: null
|
||||||
|
}
|
||||||
|
|
||||||
|
let el = render(<Markdown {...props}/>)
|
||||||
|
|
||||||
|
expect(el.text()).toEqual("")
|
||||||
|
})
|
||||||
|
|
||||||
|
it("should return no text for `undefined` as source input", function(){
|
||||||
|
let props = {
|
||||||
|
source: undefined
|
||||||
|
}
|
||||||
|
|
||||||
|
let el = render(<Markdown {...props}/>)
|
||||||
|
|
||||||
|
expect(el.text()).toEqual("")
|
||||||
|
})
|
||||||
|
|
||||||
|
it("should return no text for empty string as source input", function(){
|
||||||
|
let props = {
|
||||||
|
source: ""
|
||||||
|
}
|
||||||
|
|
||||||
|
let el = render(<Markdown {...props}/>)
|
||||||
|
|
||||||
|
expect(el.text()).toEqual("")
|
||||||
|
})
|
||||||
|
})
|
||||||
Reference in New Issue
Block a user