Skip to content

Commit

Permalink
Trim whitespace from manual completion headers, user ids and grades (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Redande committed Oct 3, 2023
1 parent ca74f4f commit a73770a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion frontend/pages/courses/[slug]/manual-completions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,10 @@ const ManualCompletions = () => {
setSubmitting(true)
setMessage(null)
setMessageSeverity("info")
const parsed = parse<CompletionData>(input, { header: true })
const parsed = parse<CompletionData>(input, {
header: true,
transformHeader: (h) => h.trim(),
})
if (parsed.errors.length > 0) {
setMessage(JSON.stringify(parsed.errors, undefined, 2))
setMessageSeverity("error")
Expand All @@ -109,6 +112,8 @@ const ManualCompletions = () => {

const data: CompletionData[] = parsed.data.map((d) => ({
...d,
user_id: d.user_id.trim(),
grade: d.grade ? d.grade.trim() : undefined,
completion_date:
d.completion_date === "" || !d.completion_date
? completionDate
Expand Down

0 comments on commit a73770a

Please sign in to comment.