Skip to content

Commit

Permalink
Revert some changes which were superseded by @dphang's changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
thchia committed Aug 31, 2020
1 parent fec9f9e commit 2ce1d38
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions packages/libs/lambda-at-edge/src/default-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,10 @@ const router = (
manifest: OriginRequestDefaultHandlerManifest
): ((uri: string) => string) => {
const {
pages: { ssr, html },
publicFiles
pages: { ssr, html }
} = manifest;

const allDynamicRoutes = { ...ssr.dynamic, ...html.dynamic };
const allNonDynamicRoutes = { ...ssr.nonDynamic, ...html.nonDynamic };

return (uri: string): string => {
let normalisedUri = uri;
Expand All @@ -122,18 +120,15 @@ const router = (
normalisedUri = uri
.replace(`/_next/data/${manifest.buildId}`, "")
.replace(".json", "");
}
// Normalise to "/" for index
normalisedUri = ["/index", ""].includes(normalisedUri)
? "/"
: normalisedUri;

if (allNonDynamicRoutes[normalisedUri]) {
return allNonDynamicRoutes[normalisedUri];
// Normalise to "/" for index data request
normalisedUri = ["/index", ""].includes(normalisedUri)
? "/"
: normalisedUri;
}

if (publicFiles[normalisedUri]) {
return publicFiles[normalisedUri];
if (ssr.nonDynamic[normalisedUri]) {
return ssr.nonDynamic[normalisedUri];
}

for (const route in allDynamicRoutes) {
Expand Down

0 comments on commit 2ce1d38

Please sign in to comment.