-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.safe.js
More file actions
36 lines (24 loc) · 771 Bytes
/
index.safe.js
File metadata and controls
36 lines (24 loc) · 771 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
const express = require('express')
const helmet = require('helmet')
var bodyParser = require('body-parser')
var app = express()
app.use(helmet())
app.use(helmet.contentSecurityPolicy({
directives: {
defaultSrc: ["'self'"],
styleSrc: ["'self'", 'maxcdn.bootstrapcdn.com']
}
}))
// parse application/x-www-form-urlencoded
app.use(bodyParser.urlencoded({ extended: false }))
// parse application/json
app.use(bodyParser.json())
const port = 3000
const safe1 = (req, res) => {
const regex1 = RegExp('hello world','g');
const str1 = req.body.msg;
let matchedStrings = regex1.exec(str1);
res.end(matchedStrings)
}
app.get('/safe1', safe1);
app.listen(port, () => console.log(`Example app listening on port ${port}!`))