summaryrefslogtreecommitdiff
path: root/bucky/util/util.js
blob: 9e0f5a49e39e05c5bf93d2a0340fb82c4d35fc9e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
var util = module.exports = {}

util.sanitizeName = function (s){ return (s || "").replace(new RegExp("[^-_a-zA-Z0-9]", 'g'), "") }
util.sanitize = function (s){ return (s || "").replace(/<>&/g, "") }

util.sanitizeUser = function (req_user) {
  // sanitize user object
  var user = JSON.parse(JSON.stringify(req_user))
  delete user.password
  return user
}

util.now = function(){ return Math.floor( (+ new Date()) / 1000 ) }