Skip to content

Commit

Permalink
catch the case where cache-control header may not exist
Browse files Browse the repository at this point in the history
  • Loading branch information
Gi60s committed Jan 6, 2021
1 parent c720249 commit 455dd78
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -313,8 +313,12 @@ async function getPem (cache) {
function getMaxAge (headers) {
debug('getting max age from cache control header')
const cacheControl = headers['cache-control']
let [, maxAge] = cacheControl.match(/max-age=(\d+)/) // Get digits
maxAge = parseInt(maxAge, 10)
let maxAge
if (cacheControl) {
const match = cacheControl.match(/max-age=(\d+)/) // Get digits
maxAge = match[1]
maxAge = parseInt(maxAge, 10)
}
if (!maxAge) {
debug('defaulting max age to 3600')
return 3600
Expand Down

0 comments on commit 455dd78

Please sign in to comment.