Skip to content

Commit 75521f6

Browse files
authored
Merge branch 'master' into lock-client-version
2 parents 40a8376 + d02dc6e commit 75521f6

File tree

7 files changed

+52
-10
lines changed

7 files changed

+52
-10
lines changed

dist/swagger-ui-bundle.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/swagger-ui-bundle.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/swagger-ui.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/swagger-ui.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/core/components/providers/markdown.jsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ const sanitizeOptions = {
1111

1212
function Markdown({ source }) {
1313
const sanitized = sanitize(source, sanitizeOptions)
14+
15+
// sometimes the sanitizer returns "undefined" as a string
16+
if(!source || !sanitized || sanitized === "undefined") {
17+
return null
18+
}
19+
1420
return <Remarkable
1521
options={{html: true, typographer: true, linkify: true, linkTarget: "_blank"}}
1622
source={sanitized}

src/core/plugins/spec/reducers.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { fromJS } from "immutable"
22
import { fromJSOrdered, validateParam } from "core/utils"
33
import win from "../../window"
4-
import findIndex from "lodash/findIndex"
54

65
import {
76
UPDATE_SPEC,
@@ -42,7 +41,7 @@ export default {
4241
[UPDATE_PARAM]: ( state, {payload} ) => {
4342
let { path, paramName, value, isXml } = payload
4443
return state.updateIn( [ "resolved", "paths", ...path, "parameters" ], fromJS([]), parameters => {
45-
const index = findIndex(parameters, p => p.get( "name" ) === paramName )
44+
const index = parameters.findIndex(p => p.get( "name" ) === paramName )
4645
if (!(value instanceof win.File)) {
4746
value = fromJSOrdered( value )
4847
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/* eslint-env mocha */
2+
import React from "react"
3+
import expect from "expect"
4+
import { render } from "enzyme"
5+
import Markdown from "components/providers/markdown"
6+
7+
describe("UI-3279: Empty Markdown inputs causing bare `undefined` in output", function(){
8+
it("should return no text for `null` as source input", function(){
9+
let props = {
10+
source: null
11+
}
12+
13+
let el = render(<Markdown {...props}/>)
14+
15+
expect(el.text()).toEqual("")
16+
})
17+
18+
it("should return no text for `undefined` as source input", function(){
19+
let props = {
20+
source: undefined
21+
}
22+
23+
let el = render(<Markdown {...props}/>)
24+
25+
expect(el.text()).toEqual("")
26+
})
27+
28+
it("should return no text for empty string as source input", function(){
29+
let props = {
30+
source: ""
31+
}
32+
33+
let el = render(<Markdown {...props}/>)
34+
35+
expect(el.text()).toEqual("")
36+
})
37+
})

0 commit comments

Comments
 (0)