diff options
author | 2024-01-25 10:24:46 +0000 | |
---|---|---|
committer | 2024-01-25 10:24:46 +0000 | |
commit | 9248f540338de9bbea3dfdbe65f7148fe2e4eb14 (patch) | |
tree | 370019dfef4ba4153510b2866bdaa1ca68f69f91 /packages/integrations/node/src/serve-static.ts | |
parent | f7f19bfa5b6b8d41a7ba3884d455961e817ec676 (diff) | |
download | astro-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.ts | 24 |
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)); |