fix: process code input to handle newlines and tabs correctly; update CSS for better text wrapping

This commit is contained in:
ishikabhoyar
2025-11-08 18:44:55 +05:30
parent 8ec0935486
commit 1d3b1c74e1
2 changed files with 8 additions and 1 deletions

View File

@@ -457,13 +457,18 @@ const CodeChallenge = () => {
try { try {
// Submit code to the backend // Submit code to the backend
const apiUrl = import.meta.env.VITE_API_URL || 'http://localhost:8080'; const apiUrl = import.meta.env.VITE_API_URL || 'http://localhost:8080';
// Ensure code has actual newlines, not escaped \n strings
// This handles cases where code might have literal "\n" instead of newlines
const processedCode = code.replace(/\\n/g, '\n').replace(/\\t/g, '\t');
const response = await fetch(`${apiUrl}/api/submit`, { const response = await fetch(`${apiUrl}/api/submit`, {
method: 'POST', method: 'POST',
headers: { headers: {
'Content-Type': 'application/json', 'Content-Type': 'application/json',
}, },
body: JSON.stringify({ body: JSON.stringify({
code: code, code: processedCode,
language: getLanguageIdentifier(language), language: getLanguageIdentifier(language),
input: '', input: '',
}), }),

View File

@@ -1673,6 +1673,8 @@ body {
margin-bottom: 6px; margin-bottom: 6px;
line-height: 1.5; line-height: 1.5;
color: #212529; color: #212529;
white-space: pre-wrap;
word-wrap: break-word;
} }
.console-line.system { .console-line.system {