summaryrefslogtreecommitdiff
path: root/packages/integrations/node/src/serve-static.ts
diff options
context:
space:
mode:
authorGravatar Alexander Niebuhr <alexander@nbhr.io> 2024-08-29 08:17:42 +0200
committerGravatar Alexander Niebuhr <alexander@nbhr.io> 2024-08-29 08:17:42 +0200
commit1b6f89c5b4b7a3e3c9cc0ca639e0a5dbfca01952 (patch)
treef9bcdf8d54f8d8f03fd75a7bff35193e72700853 /packages/integrations/node/src/serve-static.ts
parentf6819f253f48f670e210df08a984abb1b9bfde4b (diff)
downloadastro-1b6f89c5b4b7a3e3c9cc0ca639e0a5dbfca01952.tar.gz
astro-1b6f89c5b4b7a3e3c9cc0ca639e0a5dbfca01952.tar.zst
astro-1b6f89c5b4b7a3e3c9cc0ca639e0a5dbfca01952.zip
chore: supress linting
Diffstat (limited to 'packages/integrations/node/src/serve-static.ts')
-rw-r--r--packages/integrations/node/src/serve-static.ts12
1 files changed, 11 insertions, 1 deletions
diff --git a/packages/integrations/node/src/serve-static.ts b/packages/integrations/node/src/serve-static.ts
index 725f7afa6..9221594d7 100644
--- a/packages/integrations/node/src/serve-static.ts
+++ b/packages/integrations/node/src/serve-static.ts
@@ -29,23 +29,28 @@ export function createStaticHandler(app: NodeApp, options: Options) {
let isDirectory = false;
try {
isDirectory = fs.lstatSync(filePath).isDirectory();
- } catch {}
+ } catch { }
const { trailingSlash = 'ignore' } = options;
const hasSlash = urlPath.endsWith('/');
switch (trailingSlash) {
case 'never':
+ // biome-ignore lint/suspicious/noDoubleEquals: <explanation>
if (isDirectory && urlPath != '/' && hasSlash) {
+ // biome-ignore lint/style/useTemplate: <explanation>
+ // biome-ignore lint/suspicious/noFallthroughSwitchClause: <explanation>
pathname = urlPath.slice(0, -1) + (urlQuery ? '?' + urlQuery : '');
res.statusCode = 301;
res.setHeader('Location', pathname);
return res.end();
+ // biome-ignore lint/style/noUselessElse: <explanation>
} else pathname = urlPath;
// intentionally fall through
case 'ignore':
{
if (isDirectory && !hasSlash) {
+ // biome-ignore lint/style/useTemplate: <explanation>
pathname = urlPath + '/index.html';
} else pathname = urlPath;
}
@@ -53,10 +58,12 @@ export function createStaticHandler(app: NodeApp, options: Options) {
case 'always':
// trailing slash is not added to "subresources"
if (!hasSlash && !isSubresourceRegex.test(urlPath)) {
+ // biome-ignore lint/style/useTemplate: <explanation>
pathname = urlPath + '/' + (urlQuery ? '?' + urlQuery : '');
res.statusCode = 301;
res.setHeader('Location', pathname);
return res.end();
+ // biome-ignore lint/style/noUselessElse: <explanation>
} else pathname = urlPath;
break;
}
@@ -110,6 +117,7 @@ function resolveClientDir(options: Options) {
while (!serverEntryFolderURL.endsWith(serverFolder)) {
serverEntryFolderURL = path.dirname(serverEntryFolderURL);
}
+ // biome-ignore lint/style/useTemplate: <explanation>
const serverEntryURL = serverEntryFolderURL + '/entry.mjs';
const clientURL = new URL(appendForwardSlash(rel), serverEntryURL);
const client = url.fileURLToPath(clientURL);
@@ -117,9 +125,11 @@ function resolveClientDir(options: Options) {
}
function prependForwardSlash(pth: string) {
+ // biome-ignore lint/style/useTemplate: <explanation>
return pth.startsWith('/') ? pth : '/' + pth;
}
function appendForwardSlash(pth: string) {
+ // biome-ignore lint/style/useTemplate: <explanation>
return pth.endsWith('/') ? pth : pth + '/';
}