'use strict'; const crypto = require("crypto"); const sanitizeFilename = require("sanitize-filename"); module.exports = function escapeCollectionName(name) { let hash = crypto.createHash("sha256").update(name, "utf8").digest("hex"); /* We 'sanitize' the entire filename with hash included, to ensure that the result has the right maximum length. */ return sanitizeFilename(`${name}_${hash}.db`); }