Skip to content

Commit

Permalink
Revert "Fix 301 and 302 redirects. (#6001)" (#6009)
Browse files Browse the repository at this point in the history
  • Loading branch information
davisagli authored May 8, 2024
1 parent 6f2d7fc commit f01dd75
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 22 deletions.
1 change: 1 addition & 0 deletions news/6009.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Revert "Fix 301 and 302 redirects" which was not working correctly. @davisagli
5 changes: 0 additions & 5 deletions src/components/theme/View/View.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -206,11 +206,6 @@ class View extends Component {
if (this.props.error && this.props.error.code === 301) {
const redirect = flattenToAppURL(this.props.error.url).split('?')[0];
return <Redirect to={`${redirect}${this.props.location.search}`} />;
} else if (this.props.error && this.props.error.status === 302) {
const redirect = flattenToAppURL(
this.props.error.response.header.location,
).split('?')[0];
return <Redirect to={`${redirect}${this.props.location.search}`} />;
} else if (this.props.error && !this.props.connectionRefused) {
let FoundView;
if (this.props.error.status === undefined) {
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/Api/Api.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class Api {
) => {
let request;
let promise = new Promise((resolve, reject) => {
request = superagent[method](formatUrl(path)).redirects(0);
request = superagent[method](formatUrl(path));

if (params) {
request.query(params);
Expand Down
14 changes: 6 additions & 8 deletions src/helpers/Api/Api.plone.rest.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,12 @@ import Api from './Api';

jest.mock('superagent', () => ({
get: jest.fn((url) => ({
redirects: jest.fn(() => ({
url,
query: jest.fn(),
set: jest.fn(),
type: jest.fn(),
send: jest.fn(),
end: jest.fn(),
})),
url,
query: jest.fn(),
set: jest.fn(),
type: jest.fn(),
send: jest.fn(),
end: jest.fn(),
})),
}));

Expand Down
14 changes: 6 additions & 8 deletions src/helpers/Api/Api.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,12 @@ import Api from './Api';

jest.mock('superagent', () => ({
get: jest.fn((url) => ({
redirects: jest.fn(() => ({
url,
query: jest.fn(),
set: jest.fn(),
type: jest.fn(),
send: jest.fn(),
end: jest.fn(),
})),
url,
query: jest.fn(),
set: jest.fn(),
type: jest.fn(),
send: jest.fn(),
end: jest.fn(),
})),
}));

Expand Down

0 comments on commit f01dd75

Please sign in to comment.