UNPKG

simple-on-disk-cache

Version:

A simple on-disk cache, supporting local and remote filesystem targets, with time based expiration policies.

18 lines 840 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.assertIsValidOnDiskCacheKey = exports.InvalidOnDiskCacheKeyError = void 0; class InvalidOnDiskCacheKeyError extends Error { constructor({ key }) { super(` The on-disk cache key requested is invalid: '${key}'. Only alphanumeric characters and period, dash, and underscore are allowed. `.trim()); } } exports.InvalidOnDiskCacheKeyError = InvalidOnDiskCacheKeyError; const assertIsValidOnDiskCacheKey = ({ key }) => { const isValid = /^[a-zA-Z0-9.\-_]+$/.test(key); // only allow those characters, to ensure its safe for disk file name if (!isValid) throw new InvalidOnDiskCacheKeyError({ key }); }; exports.assertIsValidOnDiskCacheKey = assertIsValidOnDiskCacheKey; //# sourceMappingURL=assertIsValidOnDiskCacheKey.js.map