Skip to content

Commit

Permalink
Revert "Fix 301 and 302 redirects. (#5999)" (#6008)
Browse files Browse the repository at this point in the history
  • Loading branch information
davisagli authored May 8, 2024
1 parent 9e4f05f commit 09239bf
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 23 deletions.
1 change: 0 additions & 1 deletion packages/volto/news/5999.bugfix

This file was deleted.

5 changes: 0 additions & 5 deletions packages/volto/src/components/theme/View/View.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -209,11 +209,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 packages/volto/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 packages/volto/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 packages/volto/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 09239bf

Please sign in to comment.