Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3379471
D3554.id10802.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D3554.id10802.diff
View Options
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
Details
Attached
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)
Attached To
Mode
D3554: [server] Factor out clientURLFromLocalURL so it can be reused in website-responders.js
Attached
Detach File
Event Timeline
Log In to Comment