-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUtils.js
executable file
·43 lines (35 loc) · 1.01 KB
/
Utils.js
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
37
38
39
40
41
42
43
var express = require('express');
var router = express.Router();
/*
This file contains global helper functions
*/
var Utils = {
isEmpty : function(obj) {
for(var prop in obj) {
if(obj.hasOwnProperty(prop))
return false;
}
return true;
},
getErrorMessage : function(err) {
console.log(err);
var escErr = err.toString().replace(/</g, "<")
.replace(/>/g, ">")
return 'It looks like something didn\'t go as planned. Contact Tom Fischer or Christina Isaicu with the following error:<br><br><b>' + escErr + '</b>';
},
escapeHtml : function(unsafe) {
var reverseCoded = unsafe
.replace(/&/g, "&")
.replace(/</g, "<")
.replace(/>/g, ">")
.replace(/"/g, "\"")
.replace(/'/g, "'");
return reverseCoded
.replace(/&/g, "&")
.replace(/</g, "<")
.replace(/>/g, ">")
.replace(/"/g, """)
.replace(/'/g, "'");
}
}
module.exports = Utils;