Begin adding tests for sanitizer

Signed-off-by: Fred Boniface <fred@fjla.uk>
This commit is contained in:
Fred Boniface
2023-08-01 21:49:00 +01:00
parent 996221b221
commit 0e748d545e
6 changed files with 15 additions and 6 deletions

View File

@@ -22,13 +22,13 @@ function cleanNrcc(input: string) { // Remove newlines and then <p> tags from in
export function removeNewlineAndPTag(input: string): string {
const regex = /[\n\r]|<\/?p[^>]*>/g;
return input.replace(regex, (match) => {
return input.replace(regex, function(match) {
if (match === "\n" || match === "\r") {
return "";
} else {
return "";
}
})
});
}
async function getDomainFromEmail(mail: string) { // Needs testing

View File

@@ -13,7 +13,7 @@ export function transform(input: any): StaffLdb | null {
generatedAt: transformDateTime(data?.generatedAt) || new Date(),
locationName: data?.locationName || "Not Found",
stationManagerCode: data?.stationManagerCode || "UK",
nrccMessages: transformNrcc(data?.nrccMessages),
nrccMessages: transformNrcc(data?.nrccMessages) || undefined,
trainServices: transformTrainServices(data?.trainServices),
busServices: transformTrainServices(data?.busServices),
ferryServices: transformTrainServices(data?.ferryServices)
@@ -32,7 +32,7 @@ function transformDateTime(input: string): Date {
function transformNrcc(input: any): NrccMessage[] {
let output: NrccMessage[] = []
if (!Array.isArray(input?.message)) {
input.message = [input.message]
input.message = [input?.message]
}
for (const item of input?.message) {
let message: NrccMessage = {