mirror of
https://github.com/alexmickelson/canvasManagement.git
synced 2026-03-26 07:38:33 -06:00
when creating assignments, verify the classroom url can be swapped
This commit is contained in:
@@ -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
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user