Skip to content

Commit

Permalink
fix: Avoid redirect loop for Webviews
Browse files Browse the repository at this point in the history
fix #5007

When the "from" and the "to" location are the same, a redirect should
not be triggered otherwise it will loop and end with a
net::ERR_TOO_MANY_REDIRECTS error

Signed-off-by: Aurélien Pupier <apupier@redhat.com>
  • Loading branch information
apupier authored and azatsarynnyy committed Sep 15, 2021
1 parent 4924bc7 commit 814d9be
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## v1.18.0 - 9/30/2021

- [core, outline-view, file-system, workspace] added breadcrumbs contribution points and renderers to `core` and contributions to other packages. [#9920](https://github.com/eclipse-theia/theia/pull/9920)
- [plugin] Avoid infinite redirect loop for webview [#5007](https://github.com/eclipse-theia/theia/issues/5007)

<a name="breaking_changes_1.18.0">[Breaking Changes:](#breaking_changes_1.18.0)</a>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ async function processLocalhostRequest(event, requestUrl) {
const origin = requestUrl.origin;

const resolveRedirect = redirectOrigin => {
if (!redirectOrigin) {
if (!redirectOrigin || requestUrl.origin === redirectOrigin) {
return fetch(event.request);
}
const location = event.request.url.replace(new RegExp(`^${requestUrl.origin}(/|$)`), `${redirectOrigin}$1`);
Expand Down

0 comments on commit 814d9be

Please sign in to comment.