Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix "age" header check in XHR loader #3763

Merged
merged 1 commit into from Apr 13, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/utils/xhr-loader.ts
Expand Up @@ -8,6 +8,8 @@ import type {
} from '../types/loader';
import { LoadStats } from '../loader/load-stats';

const AGE_HEADER_LINE_REGEX = /^age:\s*[\d.]+\s*$/m;

class XhrLoader implements Loader<LoaderContext> {
private xhrSetup: Function | null;
private requestTimeout?: number;
Expand Down Expand Up @@ -253,7 +255,7 @@ class XhrLoader implements Loader<LoaderContext> {
let result: number | null = null;
if (
this.loader &&
this.loader.getAllResponseHeaders().indexOf('age') >= 0
AGE_HEADER_LINE_REGEX.test(this.loader.getAllResponseHeaders())
) {
const ageHeader = this.loader.getResponseHeader('age');
result = ageHeader ? parseFloat(ageHeader) : null;
Expand Down