Page MenuHomePhabricator

D3554.id10802.diff
No OneTemporary

D3554.id10802.diff

diff --git a/server/src/responders/landing-handler.js b/server/src/responders/landing-handler.js
--- a/server/src/responders/landing-handler.js
+++ b/server/src/responders/landing-handler.js
@@ -9,7 +9,7 @@
import { type LandingSSRProps } from '../landing/landing-ssr.react';
import { waitForStream } from '../utils/json-stream';
-import { getLandingURLFacts } from '../utils/urls';
+import { getLandingURLFacts, clientURLFromLocalURL } from '../utils/urls';
import { getMessageForException } from './utils';
async function landingHandler(req: $Request, res: $Response) {
@@ -91,15 +91,10 @@
}
}
-const { basePath, baseRoutePath } = getLandingURLFacts();
+const urlFacts = getLandingURLFacts();
+const { basePath } = urlFacts;
const { renderToNodeStream } = ReactDOMServer;
-const replaceURLRegex = new RegExp(`^${baseRoutePath}(.*)$`);
-const replaceURLModifier = `${basePath}$1`;
-function clientURLFromLocalURL(url: string): string {
- return url.replace(replaceURLRegex, replaceURLModifier);
-}
-
async function landingResponder(req: $Request, res: $Response) {
const [{ jsURL, fontURLs, cssInclude }, LandingSSR] = await Promise.all([
getAssetInfo(),
@@ -145,7 +140,7 @@
// We remove trailing slash for `react-router`
const routerBasename = basePath.replace(/\/$/, '');
- const publicURL = clientURLFromLocalURL(req.url);
+ const publicURL = clientURLFromLocalURL(req.url, urlFacts);
const reactStream = renderToNodeStream(
<LandingSSR url={publicURL} basename={routerBasename} />,
);
diff --git a/server/src/utils/urls.js b/server/src/utils/urls.js
--- a/server/src/utils/urls.js
+++ b/server/src/utils/urls.js
@@ -30,9 +30,15 @@
return landingURLFacts;
}
+function clientURLFromLocalURL(url: string, urlFacts: AppURLFacts): string {
+ const { basePath } = urlFacts;
+ return basePath + url;
+}
+
export {
getSquadCalURLFacts,
getCommAppURLFacts,
getLandingURLFacts,
getAppURLFactsFromRequestURL,
+ clientURLFromLocalURL,
};

File Metadata

Mime Type
text/plain
Expires
Thu, Nov 28, 4:26 PM (21 h, 54 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2594416
Default Alt Text
D3554.id10802.diff (1 KB)

Event Timeline