Skip to content

Commit

Permalink
Merge pull request #124 from w3bdesign/dev
Browse files Browse the repository at this point in the history
Sett opp og bruk DOMPurify
  • Loading branch information
w3bdesign authored Feb 24, 2022
2 parents 4073aeb + 159f334 commit 5aa6f99
Show file tree
Hide file tree
Showing 7 changed files with 1,097 additions and 76 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=w3bdesign_Statens-Vegvesen&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=w3bdesign_Statens-Vegvesen)
[![Language grade: JavaScript](https://img.shields.io/lgtm/grade/javascript/g/w3bdesign/Statens-Vegvesen.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/w3bdesign/Statens-Vegvesen/context:javascript)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/w3bdesign/Statens-Vegvesen/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/w3bdesign/Statens-Vegvesen/?branch=master)
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/9bc2e9dbe90c412d82ffbe19a9f878dd)](https://www.codacy.com/gh/w3bdesign/Statens-Vegvesen/dashboard?utm_source=github.com&utm_medium=referral&utm_content=w3bdesign/Statens-Vegvesen&utm_campaign=Badge_Grade)
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/9bc2e9dbe90c412d82ffbe19a9f878dd)](https://www.codacy.com/gh/w3bdesign/Statens-Vegvesen/dashboard?utm_source=github.com&utm_medium=referral&utm_content=w3bdesign/Statens-Vegvesen&utm_campaign=Badge_Grade)
[![DeepSource](https://deepsource.io/gh/w3bdesign/Statens-Vegvesen.svg/?label=active+issues&show_trend=true&token=vdKpHAssiI6fTmx5L1VmPilg)](https://deepsource.io/gh/w3bdesign/Statens-Vegvesen/?ref=repository-badge)

# Display vehicle information from Statens Vegvesen (Norway)
Expand All @@ -16,7 +16,7 @@ This application uses Serverless with Typescript for the backend.

## Features

- Javascript with OOP and Typescript
- Javascript with OOP and Typescript
- Serverless backend with Typescript
- Bootstrap 5
- Animate.css for animations
Expand Down
26 changes: 15 additions & 11 deletions api/getRegNummer.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import fetch from "node-fetch";
import { sanitize } from "dompurify";
import { sanitize } from "isomorphic-dompurify";
import { VercelRequest, VercelResponse } from "@vercel/node";

export default function getRegNummer(
Expand All @@ -11,16 +11,20 @@ export default function getRegNummer(
if (regNummer !== undefined) {
fetch(urlToFetch)
.then((response) => response.json())
.then((data: VercelResponse) => {


const sanitizedData = sanitize(data);


console.log("Old data: ", data)
console.log("sanitizedData: ", sanitizedData)
res.send(sanitizedData);
})
.then(
({
kjennemerke,
registrering: { forstegangsregistreringEier },
periodiskKjoretoykontroll: { sistKontrollert },
}: VercelResponse) => {
const sanitizedData = {
kjennemerke: sanitize(kjennemerke),
forstegangsregistreringEier: sanitize(forstegangsregistreringEier),
sistKontrollert: sanitize(sistKontrollert),
};
res.send(sanitizedData);
}
)
.catch(() => {
return;
});
Expand Down
Loading

1 comment on commit 5aa6f99

@vercel
Copy link

@vercel vercel bot commented on 5aa6f99 Feb 24, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.