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

1234567891011121314151617181920212223242526272829
  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. Object.defineProperty(exports, "__esModule", { value: true });
  9. exports.noRevisionForURLsMatchingTransform = void 0;
  10. const errors_1 = require("./errors");
  11. function noRevisionForURLsMatchingTransform(regexp) {
  12. if (!(regexp instanceof RegExp)) {
  13. throw new Error(errors_1.errors['invalid-dont-cache-bust']);
  14. }
  15. return (originalManifest) => {
  16. const manifest = originalManifest.map((entry) => {
  17. if (typeof entry.url !== 'string') {
  18. throw new Error(errors_1.errors['manifest-entry-bad-url']);
  19. }
  20. if (entry.url.match(regexp)) {
  21. entry.revision = null;
  22. }
  23. return entry;
  24. });
  25. return { manifest };
  26. };
  27. }
  28. exports.noRevisionForURLsMatchingTransform = noRevisionForURLsMatchingTransform;