no-revision-for-urls-matching-transform.js 703 B

123456789101112131415161718192021222324252627282930313233
  1. "use strict";
  2. /*
  3. Copyright 2018 Google LLC
  4. Use of this source code is governed by an MIT-style
  5. license that can be found in the LICENSE file or at
  6. https://opensource.org/licenses/MIT.
  7. */
  8. const errors = require('./errors');
  9. module.exports = regexp => {
  10. if (!(regexp instanceof RegExp)) {
  11. throw new Error(errors['invalid-dont-cache-bust']);
  12. }
  13. return originalManifest => {
  14. const manifest = originalManifest.map(entry => {
  15. if (typeof entry.url !== 'string') {
  16. throw new Error(errors['manifest-entry-bad-url']);
  17. }
  18. if (entry.url.match(regexp)) {
  19. entry.revision = null;
  20. }
  21. return entry;
  22. });
  23. return {
  24. manifest
  25. };
  26. };
  27. };