* Check path parameter * @param path path * @param url URL * @param method HTTP method
(path: (string | RegExp | PathObject)[], url: string, method: string)
| 45 | * @param method HTTP method |
| 46 | */ |
| 47 | function pathCheck(path: (string | RegExp | PathObject)[], url: string, method: string): boolean { |
| 48 | let res = false |
| 49 | for (const p of path) { |
| 50 | if (typeof p === 'string') res = res || p === url |
| 51 | else if (p instanceof RegExp) { |
| 52 | const regexPath: RegExp = p |
| 53 | res = res || regexPath.test(url) |
| 54 | } else { |
| 55 | const objectPath: PathObject = p |
| 56 | res = res || (objectPath.url === url && objectPath.methods.indexOf(method) !== -1) |
| 57 | } |
| 58 | if (res) return res |
| 59 | } |
| 60 | return res |
| 61 | } |
| 62 | |
| 63 | /** |
| 64 | * Middleware for conditional middleware executing. |