Skip to content

Commit

Permalink
Merge pull request video-dev#3763 from video-dev/bugfix/age-header-regex
Browse files Browse the repository at this point in the history
Fix "age" header check in XHR loader
  • Loading branch information
robwalch authored Apr 13, 2021
2 parents aa6e83d + 03f473b commit 92bca82
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/utils/xhr-loader.ts
Original file line number Diff line number Diff line change
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

0 comments on commit 92bca82

Please sign in to comment.