Skip to content

Commit 475b19a

Browse files
committed
chore: add check before splitting csrfCookie
1 parent c03a36a commit 475b19a

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

cypress/support/commands.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ Cypress.Commands.add('getCSRFToken', () => {
4444
return cy.request('GET', 'http://localhost:8080/api/v1/repo').then((res) => {
4545
const cookies = res.headers['set-cookie'];
4646
const csrfCookie = cookies.find(c => c.startsWith('csrf='));
47+
48+
if (!csrfCookie) {
49+
throw new Error('No CSRF cookie found');
50+
}
51+
4752
const token = decodeURIComponent(csrfCookie.split('=')[1].split(';')[0]);
4853
return cy.wrap(token);
4954
});

0 commit comments

Comments
 (0)