Niedzielski has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/395572 )

Change subject: Update: handle redirects manually on the client too
......................................................................

Update: handle redirects manually on the client too

If the client happens to support redirects, handle them manually as the
server does which would allow the client to obtain the correct title.

Change-Id: I3320ddc0a78e774357f9e17511630c100502dac6
---
M src/common/http/fetch.ts
1 file changed, 2 insertions(+), 8 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/marvin refs/changes/72/395572/1

diff --git a/src/common/http/fetch.ts b/src/common/http/fetch.ts
index 4d7aa09..80fdfc2 100644
--- a/src/common/http/fetch.ts
+++ b/src/common/http/fetch.ts
@@ -2,9 +2,6 @@
 import { unmarshalPageTitleID } from 
"../marshallers/page-base/page-base-unmarshaller"; // eslint-disable-line 
max-len
 import { IsomorphicResponse } from "../types/isomorphic-unfetch-extras";
 
-/** true if executing on server, false otherwise. */
-const server = typeof window !== "object";
-
 export class FetchError extends Error {
   status: number;
   url: string;
@@ -48,12 +45,9 @@
   input: RequestInfo,
   init?: RequestInit
 ): Promise<IsomorphicResponse> {
-  // Setting the redirect mode to "error" doesn't appear to yield the status
-  // code so "manual" is used instead.
-  const redirect = server ? "manual" : undefined;
-  return fetcher(input, { redirect, ...init }).then(response => {
+  return fetcher(input, { redirect: "manual", ...init }).then(response => {
     const requestURL = typeof input === "string" ? input : input.url;
-    if (server && response.status >= 300 && response.status <= 399) {
+    if (response.status >= 300 && response.status <= 399) {
       const url = response.headers.get("location");
       if (url) throw new RedirectError(response.status, url);
 

-- 
To view, visit https://gerrit.wikimedia.org/r/395572
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I3320ddc0a78e774357f9e17511630c100502dac6
Gerrit-PatchSet: 1
Gerrit-Project: marvin
Gerrit-Branch: master
Gerrit-Owner: Niedzielski <[email protected]>
Gerrit-Reviewer: Sniedzielski <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to