From bfffdbc4d876c4a8b509e7577278513967dd417e Mon Sep 17 00:00:00 2001 From: Nicholas Palenchar Date: Sun, 25 Aug 2019 17:10:17 -0400 Subject: [PATCH] closes #36 raw body option --- pages/index.vue | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/pages/index.vue b/pages/index.vue index 82788ad02..52cc456d6 100644 --- a/pages/index.vue +++ b/pages/index.vue @@ -36,8 +36,10 @@ - - Raw Input + + + +
@@ -252,7 +254,6 @@ return validIP.test(this.url) || validHostname.test(this.url); }, rawRequestBody() { - debugger; const { bodyParams } = this @@ -338,7 +339,6 @@ xhr.setRequestHeader('Authorization', 'Bearer ' + this.bearerToken); } if (this.method === 'POST' || this.method === 'PUT') { - debugger; const requestBody = this.rawInput ? this.rawParams : this.rawRequestBody; xhr.setRequestHeader('Content-Length', requestBody.length) xhr.setRequestHeader('Content-Type', `${this.contentType}; charset=utf-8`) @@ -382,8 +382,7 @@ }, formatRawParams(event) { if ((event.which !== 13 && event.which !== 9)) { - console.log('not not returning'); - return + return; } const textBody = event.target.value; @@ -391,8 +390,17 @@ const textAfterCursor = textBody.substring(event.target.selectionEnd); if (event.which === 13) { - const lastLine = textBody.split('\n').slice(-1)[0]; + event.preventDefault(); + const oldSelectionStart = event.target.selectionStart; + const lastLine = textBeforeCursor.split('\n').slice(-1)[0]; const rightPadding = lastLine.match(/([\s\t]*).*/)[1] || ""; + event.target.value = textBeforeCursor + '\n' + rightPadding + textAfterCursor; + setTimeout(() => event.target.selectionStart = event.target.selectionEnd = oldSelectionStart + rightPadding.length + 1, 1); + return; + + // const lastLine = textBeforeCursor.split('\n').slice(-1)[0]; + // const rightPadding = lastLine.match(/([\s\t]*).*/)[1] || ""; + event.target.value = textBeforeCursor + '\n' + rightPadding + textAfterCursor setTimeout(() => event.target.value = textBeforeCursor + '\n' + rightPadding + textAfterCursor, 1); } else if (event.which === 9) {