mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-05-28 18:26:54 +00:00
test: minor fix to how cookies are passed around (#55259)
This commit is contained in:
committed by
GitHub
parent
dda9c929b0
commit
fd1bf0dd5a
+8
-1
@@ -34,6 +34,13 @@ export const getCsrfToken = (setCookies: string[]): string | undefined => {
|
||||
|
||||
export const ORIGIN = 'https://www.freecodecamp.org';
|
||||
|
||||
export const getCookies = (setCookies: string[]): string => {
|
||||
for (const cookie of setCookies) {
|
||||
expect(cookie).toMatch(/.*=.*/);
|
||||
}
|
||||
return setCookies.map(cookie => cookie.split(';')[0]).join('; ');
|
||||
};
|
||||
|
||||
export function superRequest(
|
||||
resource: string,
|
||||
config: {
|
||||
@@ -48,7 +55,7 @@ export function superRequest(
|
||||
const req = requests[method](resource).set('Origin', ORIGIN);
|
||||
|
||||
if (setCookies) {
|
||||
void req.set('Cookie', setCookies);
|
||||
void req.set('Cookie', getCookies(setCookies));
|
||||
}
|
||||
|
||||
const csrfToken = (setCookies && getCsrfToken(setCookies)) ?? '';
|
||||
|
||||
Reference in New Issue
Block a user