• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1const { URL, format } = require('url')
2
3// options passed to url.format() when generating a key
4const formatOptions = {
5  auth: false,
6  fragment: false,
7  search: true,
8  unicode: false,
9}
10
11// returns a string to be used as the cache key for the Request
12const cacheKey = (request) => {
13  const parsed = new URL(request.url)
14  return `make-fetch-happen:request-cache:${format(parsed, formatOptions)}`
15}
16
17module.exports = cacheKey
18