From f876be09106ac07b068f418b890d320374d9ef44 Mon Sep 17 00:00:00 2001 From: sawirricardo Date: Tue, 20 Jun 2023 22:08:48 +0700 Subject: [PATCH] bugfix --- resources/views/web-console/index.blade.php | 8 ++++---- src/Http/Controllers/WebConsoleController.php | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/resources/views/web-console/index.blade.php b/resources/views/web-console/index.blade.php index 439df8d..e65a3cc 100644 --- a/resources/views/web-console/index.blade.php +++ b/resources/views/web-console/index.blade.php @@ -37,13 +37,13 @@ axios.post(`{{ $interactUrl ?? '' }}`, { command: line, working_directory: workingDirectory, - }).then((result) => { + }).then((res) => { term.writeln(``); - if (result.output) { + if (res.data.output) { commands = [...commands, line]; - term.writeln(result.output); + term.writeln(res.data.output); } - workingDirectory = result.working_directory + workingDirectory = res.data.working_directory term.write(`${workingDirectory} => $ `) }) } diff --git a/src/Http/Controllers/WebConsoleController.php b/src/Http/Controllers/WebConsoleController.php index fcd3798..d52b53f 100644 --- a/src/Http/Controllers/WebConsoleController.php +++ b/src/Http/Controllers/WebConsoleController.php @@ -27,13 +27,13 @@ public function interact() if ($cmd->substr(0, 2) == 'cd') { if (chdir($cmd->substr(3))) { return response()->json([ - 'output' => PHP_EOL, + 'output' => "\r\n", 'working_directory' => getcwd(), ]); } return response()->json([ - 'output' => 'cd: Unable to change directory'.PHP_EOL, + 'output' => 'cd: Unable to change directory'."\r\n", 'working_directory' => getcwd(), ]); } @@ -42,14 +42,14 @@ public function interact() if ($output === false) { return response()->json([ - 'output' => PHP_EOL, + 'output' => "\r\n", 'working_directory' => getcwd(), ]); } return response()->json([ 'output' => str($output) - ->replace("\n", PHP_EOL) + ->replace("\n", "\r\n") ->toString(), 'working_directory' => getcwd(), ]);