You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
npmbar/src/db/escape-collection-name.js

11 lines
403 B
JavaScript

'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`);
}