summaryrefslogtreecommitdiff
path: root/packages/integrations/node/src/serve-static.ts
diff options
context:
space:
mode:
authorGravatar Marvin <ematipico@users.noreply.github.com> 2024-01-25 10:24:46 +0000
committerGravatar astrobot-houston <fred+astrobot@astro.build> 2024-01-25 10:24:46 +0000
commit9248f540338de9bbea3dfdbe65f7148fe2e4eb14 (patch)
tree370019dfef4ba4153510b2866bdaa1ca68f69f91 /packages/integrations/node/src/serve-static.ts
parentf7f19bfa5b6b8d41a7ba3884d455961e817ec676 (diff)
downloadastro-9248f540338de9bbea3dfdbe65f7148fe2e4eb14.tar.gz
astro-9248f540338de9bbea3dfdbe65f7148fe2e4eb14.tar.zst
astro-9248f540338de9bbea3dfdbe65f7148fe2e4eb14.zip
[ci] format
Diffstat (limited to 'packages/integrations/node/src/serve-static.ts')
-rw-r--r--packages/integrations/node/src/serve-static.ts24
1 files changed, 11 insertions, 13 deletions
diff --git a/packages/integrations/node/src/serve-static.ts b/packages/integrations/node/src/serve-static.ts
index a88b1332f..b0b1e1766 100644
--- a/packages/integrations/node/src/serve-static.ts
+++ b/packages/integrations/node/src/serve-static.ts
@@ -32,31 +32,29 @@ export function createStaticHandler(app: NodeApp, options: Options) {
const hasSlash = urlPath.endsWith('/');
switch (trailingSlash) {
- case "never":
- if (isDirectory && (urlPath != '/') && hasSlash) {
- pathname = urlPath.slice(0, -1) + (urlQuery ? "?" + urlQuery : "");
+ case 'never':
+ if (isDirectory && urlPath != '/' && hasSlash) {
+ pathname = urlPath.slice(0, -1) + (urlQuery ? '?' + urlQuery : '');
res.statusCode = 301;
res.setHeader('Location', pathname);
return res.end();
} else pathname = urlPath;
- // intentionally fall through
- case "ignore":
+ // intentionally fall through
+ case 'ignore':
{
if (isDirectory && !hasSlash) {
- pathname = urlPath + "/index.html";
- } else
- pathname = urlPath;
+ pathname = urlPath + '/index.html';
+ } else pathname = urlPath;
}
break;
- case "always":
+ case 'always':
if (!hasSlash) {
- pathname = urlPath + '/' +(urlQuery ? "?" + urlQuery : "");
+ pathname = urlPath + '/' + (urlQuery ? '?' + urlQuery : '');
res.statusCode = 301;
res.setHeader('Location', pathname);
return res.end();
- } else
- pathname = urlPath;
- break;
+ } else pathname = urlPath;
+ break;
}
// app.removeBase sometimes returns a path without a leading slash
pathname = prependForwardSlash(app.removeBase(pathname));