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(pacer): Prevents error by checking filingCookie existence #377

Merged
merged 1 commit into from
Jul 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Features:
- Inserts the RECAP button and [R] icons to the ACMS Docket report. ([#374](https://github.com/freelawproject/recap-chrome/pull/374))
- Displays the warning about combined PDFs on the download page.([#376](https://github.com/freelawproject/recap-chrome/pull/376))
- Introduces logic to upload ACMS attachment pages to CourtListener([#375](https://github.com/freelawproject/recap-chrome/pull/375))
- Introduces validation for the cookie used to identify filing account users.([#371](https://github.com/freelawproject/recap/issues/371), [#377](https://github.com/freelawproject/recap-chrome/pull/377)).

Changes:
- Updates style and replace old logos with new ones([#378](https://github.com/freelawproject/recap-chrome/pull/378))
Expand Down
25 changes: 25 additions & 0 deletions spec/PacerSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,31 @@ describe('The PACER module', function () {
});
});

describe('hasFilingCookie', function () {
const filingAccountCookie =
'PacerSession=B7yuvmcj2F...9p5nDzEXsHE; ' + 'isFilingAccount=true';
const nonFilingAccountCookie =
'PacerUser=B7yuvmcj2F...9p5nDzEXsHE; ' + 'PacerPref=receipt=Y';
const nonLoggedInCookie = 'PacerSession=unvalidated; PacerPref=receipt=Y';
const nonsenseCookie = 'Foo=barbaz; Baz=bazbar; Foobar=Foobar';

it('returns true for a valid cookie from a filing account', function () {
expect(PACER.hasFilingCookie(filingAccountCookie)).toBe(true);
});

it('returns false for cookies from a non-filing account', function () {
expect(PACER.hasFilingCookie(nonFilingAccountCookie)).toBe(false);
});

it('returns false for a non-logged in cookie', function () {
expect(PACER.hasFilingCookie(nonLoggedInCookie)).toBe(false);
});

it('returns false for nonsense cookie', function () {
expect(PACER.hasFilingCookie(nonsenseCookie)).toBe(false);
});
});

describe('isAppellateCourt', function () {
it('returns true for an appellate court', function () {
expect(PACER.isAppellateCourt('ca5')).toBe(true);
Expand Down
2 changes: 1 addition & 1 deletion src/pacer.js
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,7 @@ let PACER = {
let filingCookie = cookieString.split('; ')
.find((row) => row.startsWith('isFilingAccount'))
?.split('=')[1];
return !!filingCookie.match(/true/);
return !!(filingCookie && filingCookie.match(/true/));
},

// Returns true if the given court identifier is for an appellate court.
Expand Down
Loading