571 - allow and encode multiline uri form data

This commit is contained in:
Louis Wilke 2023-10-19 21:28:21 +02:00
parent f8f38802a9
commit ddddab8112
4 changed files with 9 additions and 4 deletions

View File

@ -107,6 +107,7 @@ const FormUrlEncodedParams = ({ item, collection }) => {
'value' 'value'
) )
} }
allowNewlines={true}
onRun={handleRun} onRun={handleRun}
collection={collection} collection={collection}
/> />

View File

@ -57,6 +57,7 @@ class SingleLineEditor extends Component {
} }
componentDidMount() { componentDidMount() {
// Initialize CodeMirror as a single line editor // Initialize CodeMirror as a single line editor
/** @type {import("codemirror").Editor} */
this.editor = CodeMirror(this.editorRef.current, { this.editor = CodeMirror(this.editorRef.current, {
lineWrapping: false, lineWrapping: false,
lineNumbers: false, lineNumbers: false,
@ -84,7 +85,10 @@ class SingleLineEditor extends Component {
} }
}, },
'Alt-Enter': () => { 'Alt-Enter': () => {
if (this.props.onRun) { if (this.props.allowNewlines) {
this.editor.setValue(this.editor.getValue() + '\n');
this.editor.setCursor({ line: this.editor.lineCount(), ch: 0 });
} else if (this.props.onRun) {
this.props.onRun(); this.props.onRun();
} }
}, },

View File

@ -104,7 +104,7 @@ const mapPairListToKeyValPairs = (pairList = [], parseEnabled = true) => {
} }
return _.map(pairList[0], (pair) => { return _.map(pairList[0], (pair) => {
let name = _.keys(pair)[0]; let name = _.keys(pair)[0];
let value = pair[name]; let value = decodeURIComponent(pair[name]);
if (!parseEnabled) { if (!parseEnabled) {
return { return {

View File

@ -154,7 +154,7 @@ ${indentString(body.sparql)}
if (enabled(body.formUrlEncoded).length) { if (enabled(body.formUrlEncoded).length) {
bru += `\n${indentString( bru += `\n${indentString(
enabled(body.formUrlEncoded) enabled(body.formUrlEncoded)
.map((item) => `${item.name}: ${item.value}`) .map((item) => `${item.name}: ${encodeURIComponent(item.value)}`)
.join('\n') .join('\n')
)}`; )}`;
} }
@ -162,7 +162,7 @@ ${indentString(body.sparql)}
if (disabled(body.formUrlEncoded).length) { if (disabled(body.formUrlEncoded).length) {
bru += `\n${indentString( bru += `\n${indentString(
disabled(body.formUrlEncoded) disabled(body.formUrlEncoded)
.map((item) => `~${item.name}: ${item.value}`) .map((item) => `~${item.name}: ${encodeURIComponent(item.value)}`)
.join('\n') .join('\n')
)}`; )}`;
} }