Skip to content

feat: add globPattern support for both wildcard modes - #634

Open
prateek31-ops wants to merge 1 commit into
fastify:mainfrom
prateek31-ops:feat/glob-pattern
Open

prateek31-ops wants to merge 1 commit into
fastify:mainfrom
prateek31-ops:feat/glob-pattern

Conversation

@prateek31-ops

Copy link
Copy Markdown

Description

Adds a globPattern configuration option to filter static files using custom glob patterns.

Related to #178.

Changes

  • Support custom glob patterns in both wildcard modes.
  • Preserve existing behaviour when globPattern is omitted.
  • Support newly created matching files when wildcard routing is enabled.
  • Validate the configuration option.
  • Update TypeScript definitions and documentation.

Tests

  • Matching and non-matching files.
  • Nested file paths.
  • Both wildcard modes.
  • Dynamically created files.
  • Invalid configuration values.
  • Directory index and HEAD requests.

Example

fastify.register(require('@fastify/static'), {
  root: path.join(__dirname, 'public'),
  globPattern: '**/*.{js,css}'
})

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants