diff options
author | 2025-02-12 10:34:32 +0000 | |
---|---|---|
committer | 2025-02-12 10:34:32 +0000 | |
commit | 23094a1f48d0dfb12c5866a3713f52106ef927dd (patch) | |
tree | 33c68bbe2c503450eb916eb3983dda3b7053ef0b /packages/integrations/node/src/serve-static.ts | |
parent | 7d94b49870b9258e1ab242c5410cf6da20b5c78b (diff) | |
download | astro-23094a1f48d0dfb12c5866a3713f52106ef927dd.tar.gz astro-23094a1f48d0dfb12c5866a3713f52106ef927dd.tar.zst astro-23094a1f48d0dfb12c5866a3713f52106ef927dd.zip |
fix: use shared helper for file extensions (#13223)
* fix: use shared helper for file extensions
* Lock
Diffstat (limited to 'packages/integrations/node/src/serve-static.ts')
-rw-r--r-- | packages/integrations/node/src/serve-static.ts | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/packages/integrations/node/src/serve-static.ts b/packages/integrations/node/src/serve-static.ts index c7ec56aae..3b1b1e9a7 100644 --- a/packages/integrations/node/src/serve-static.ts +++ b/packages/integrations/node/src/serve-static.ts @@ -5,9 +5,8 @@ import url from 'node:url'; import type { NodeApp } from 'astro/app/node'; import send from 'send'; import type { Options } from './types.js'; +import { hasFileExtension } from '@astrojs/internal-helpers/path'; -// check for a dot followed by a extension made up of lowercase characters -const isSubresourceRegex = /.+\.[a-z]+$/i; /** * Creates a Node.js http listener for static files and prerendered pages. @@ -56,7 +55,7 @@ export function createStaticHandler(app: NodeApp, options: Options) { } case 'always': { // trailing slash is not added to "subresources" - if (!hasSlash && !isSubresourceRegex.test(urlPath)) { + if (!hasSlash && !hasFileExtension(urlPath)) { pathname = urlPath + '/' + (urlQuery ? '?' + urlQuery : ''); res.statusCode = 301; res.setHeader('Location', pathname); |