Skip to content
This repository was archived by the owner on May 26, 2023. It is now read-only.

Commit 1c10269

Browse files
asiffermannabernix
authored andcommitted
fix: 'addLineBreaks' regex in 'createSDL' to avoid line-breaking comment lines (graphql#1245)
1 parent 58cc0fc commit 1c10269

File tree

1 file changed

+2
-2
lines changed
  • packages/graphql-playground-react/src/components/Playground/util

1 file changed

+2
-2
lines changed

packages/graphql-playground-react/src/components/Playground/util/createSDL.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,9 @@ function getTypeInstance(type) {
6565
function addLineBreaks(sdl: string, commentsDisabled: boolean = true) {
6666
const noNewLines = sdl.replace(/^\s*$(?:\r\n?|\n)/gm, '')
6767
// Line Break all Brackets
68-
const breakBrackets = noNewLines.replace(/[}]/gm, '$&\r\n')
68+
const breakBrackets = noNewLines.replace(/^[}]/gm, '$&\r\n')
6969
// Line Break all Scalars
70-
const withLineBreaks = breakBrackets.replace(/(?:scalar )\w+/g, '$&\r\n')
70+
const withLineBreaks = breakBrackets.replace(/^(?:scalar )\w+/gm, '$&\r\n')
7171

7272
if (commentsDisabled) {
7373
return withLineBreaks

0 commit comments

Comments
 (0)