Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to filter files #172

Merged
merged 3 commits into from Feb 18, 2021
Merged

Add option to filter files #172

merged 3 commits into from Feb 18, 2021

Conversation

ghostd
Copy link
Contributor

@ghostd ghostd commented Jan 30, 2021

Checklist

Closes #145

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

index.js Outdated
@@ -50,6 +56,10 @@ async function fastifyStatic (fastify, opts) {
}
}

if (!allowedPath(pathname, options.root)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With this check, it would be possible to skip the function declaration and the function call that returns true

Suggested change
if (!allowedPath(pathname, options.root)) {
if (allowedPath && !allowedPath(pathname, options.root)) {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

index.js Outdated
@@ -39,6 +43,8 @@ async function fastifyStatic (fastify, opts) {
maxAge: opts.maxAge
}

const allowedPath = opts.allowedPath || allowAllPaths
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const allowedPath = opts.allowedPath || allowAllPaths
const allowedPath = opts.allowedPath

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

index.js Outdated Show resolved Hide resolved
Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@mcollina mcollina merged commit 9a2e352 into fastify:master Feb 18, 2021
@ghostd ghostd deleted the gh-145 branch February 18, 2021 16:36
@ghost ghost mentioned this pull request Mar 5, 2021
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.

Support filtering files by extension
3 participants