when creating assignments, verify the classroom url can be swapped

This commit is contained in:
2025-08-29 11:05:50 -06:00
parent 5f408749e4
commit 523a05d45e
3 changed files with 20 additions and 2 deletions

View File

@@ -36,6 +36,7 @@ export const canvasAssignmentService = {
{
source: "insert_github_classroom_url",
destination: localAssignment.githubClassroomAssignmentShareLink || "",
strict: true,
},
],
});
@@ -93,6 +94,7 @@ export const canvasAssignmentService = {
source: "insert_github_classroom_url",
destination:
localAssignment.githubClassroomAssignmentShareLink || "",
strict: true,
},
],
}),

View File

@@ -87,11 +87,25 @@ export function markdownToHTMLSafe({
markdownString: string;
settings: LocalCourseSettings;
convertImages?: boolean;
replaceText?: { source: string; destination: string }[];
replaceText?: { source: string; destination: string; strict?: boolean }[];
}) {
const html = markdownToHtmlNoImages(markdownString);
const replacedHtml = replaceText.reduce(
(acc, { source, destination }) => acc.replaceAll(source, destination),
(acc, { source, destination, strict = false }) => {
if (strict) {
if (typeof destination === "undefined" || destination === null) {
throw new Error(
`Text replacement failed: destination is undefined for source "${source}"`
);
}
if (destination === "") {
throw new Error(
`Text replacement failed: destination is empty string for source "${source}"`
);
}
}
return acc.replaceAll(source, destination);
},
html
);