Skip to content

Commit

Permalink
fix(scheduler-utils): only cache origin in Location header when follo…
Browse files Browse the repository at this point in the history
…wing redirects #454
  • Loading branch information
TillaTheHun0 committed Feb 12, 2024
1 parent 7bb32b9 commit c5893d0
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion scheduler-utils/src/client/scheduler.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ export function checkForRedirectWith ({ fetch }) {
const response = await fetch(`${url}?process-id=${process}`, { method: 'GET', redirect: 'manual' })
// In an HTTP redirect the Location header is the new url
if ([301, 302, 307, 308].includes(response.status)) {
return response.headers.get('Location')
return new URL(response.headers.get('Location')).origin
}
return url
}
Expand Down
2 changes: 1 addition & 1 deletion scheduler-utils/src/client/scheduler.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const mockFetch = (url, options) => {
status: 302,
headers: {
get: (header) => {
if (header === 'Location') return 'http://newlocation.com'
if (header === 'Location') return 'http://newlocation.com?process-id=123'
}
}
})
Expand Down

0 comments on commit c5893d0

Please sign in to comment.