messages.mjs 781 B

123456789101112131415161718192021222324252627282930
  1. /*
  2. Copyright 2018 Google LLC
  3. Use of this source code is governed by an MIT-style
  4. license that can be found in the LICENSE file or at
  5. https://opensource.org/licenses/MIT.
  6. */
  7. import {logger} from 'workbox-core/_private/logger.mjs';
  8. import '../_version.mjs';
  9. const getFriendlyURL = (url) => {
  10. const urlObj = new URL(url, location);
  11. if (urlObj.origin === location.origin) {
  12. return urlObj.pathname;
  13. }
  14. return urlObj.href;
  15. };
  16. export const messages = {
  17. strategyStart: (strategyName, request) => `Using ${strategyName} to ` +
  18. `respond to '${getFriendlyURL(request.url)}'`,
  19. printFinalResponse: (response) => {
  20. if (response) {
  21. logger.groupCollapsed(`View the final response here.`);
  22. logger.log(response);
  23. logger.groupEnd();
  24. }
  25. },
  26. };