exceptions with methods
This commit is contained in:
parent
2a3d5b4425
commit
167e26117a
18
index.js
18
index.js
@ -147,6 +147,20 @@ async function request_handler_authenticate (session, user, key, res, next) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* check if a filter matches a request
|
||||
*
|
||||
* @param {any} req request
|
||||
* @param {any} filter filter
|
||||
* @returns {boolean} true if filter matches
|
||||
*/
|
||||
function filter_matches (req, filter) {
|
||||
if (filter instanceof RegExp && filter.test (req.url))
|
||||
return true;
|
||||
return req.method === filter.method
|
||||
&& filter.regex
|
||||
&& filter.regex.test (req.url);
|
||||
}
|
||||
|
||||
/**
|
||||
* handles http requests
|
||||
@ -157,8 +171,8 @@ async function request_handler_authenticate (session, user, key, res, next) {
|
||||
*/
|
||||
async function request_handler (req, res, next) {
|
||||
if (Array.isArray (me.ignore_paths)) {
|
||||
for (const regex of me.ignore_paths) {
|
||||
if (regex.test (req.url)) {
|
||||
for (const ignore of me.ignore_paths) {
|
||||
if (filter_matches (req, ignore)) {
|
||||
next ();
|
||||
return;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user