mirror of
https://github.com/arthurfiorette/axios-cache-interceptor.git
synced 2025-12-08 17:36:16 +00:00
fix: Interpret max-age=0 as a valid cache-control header (#253)
* fix: Interpret `max-age=0` as a valid `cache-control` header * tests: added max-age=0 test * fix: fixed linting Co-authored-by: arthurfiorette <arthur.fiorette@gmail.com>
This commit is contained in:
parent
e1d6bdd955
commit
728b69d71a
@ -28,7 +28,7 @@ export const defaultHeaderInterpreter: HeadersInterpreter = (headers) => {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (maxAge) {
|
||||
if (maxAge !== undefined) {
|
||||
const age = headers[Header.Age];
|
||||
|
||||
if (!age) {
|
||||
|
||||
@ -30,4 +30,13 @@ describe('test Cache-Control header', () => {
|
||||
// 10 Seconds in milliseconds
|
||||
expect(result).toBe(10 * 1000);
|
||||
});
|
||||
|
||||
it('tests with max-age of 0', () => {
|
||||
const result = defaultHeaderInterpreter({
|
||||
[Header.CacheControl]: 'max-age=0'
|
||||
});
|
||||
|
||||
expect(result).toBe(0);
|
||||
expect(result).not.toBe('not enough headers');
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user