Begin adding tests for sanitizer
Signed-off-by: Fred Boniface <fred@fjla.uk>
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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 = {
|
||||
|
||||
Reference in New Issue
Block a user