mirror of
https://github.com/BobbyWibowo/lolisafe.git
synced 2025-02-23 21:59:05 +00:00
feat: ignore option for ServeStaticQuick class
This commit is contained in:
parent
414afc7ae6
commit
ab4f8263de
@ -54,6 +54,11 @@ class ServeStaticQuick {
|
|||||||
options.etag = true
|
options.etag = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (options.ignore && typeof options.ignore !== 'function') {
|
||||||
|
// Unlike LiveDirectory, we only support function for simplicity's sake
|
||||||
|
throw new TypeError('Middleware option ignore must be a function')
|
||||||
|
}
|
||||||
|
|
||||||
if (options.lastModified === undefined) {
|
if (options.lastModified === undefined) {
|
||||||
options.lastModified = true
|
options.lastModified = true
|
||||||
}
|
}
|
||||||
@ -140,7 +145,10 @@ class ServeStaticQuick {
|
|||||||
case 'add':
|
case 'add':
|
||||||
case 'addDir':
|
case 'addDir':
|
||||||
case 'change':
|
case 'change':
|
||||||
this.files.set(relPath, stat)
|
// Ensure relative path does not pass ignore function if set
|
||||||
|
if (!this.#options.ignore || !this.#options.ignore(relPath, stat)) {
|
||||||
|
this.files.set(relPath, stat)
|
||||||
|
}
|
||||||
break
|
break
|
||||||
case 'unlink':
|
case 'unlink':
|
||||||
case 'unlinkDir':
|
case 'unlinkDir':
|
||||||
|
Loading…
Reference in New Issue
Block a user