(path: string)
| 47 | const { regex, paramNames } = compilePathPattern(pattern); |
| 48 | |
| 49 | const matcher = (path: string): Optional<Record<string, string>> => { |
| 50 | const match = regex.exec(path); |
| 51 | |
| 52 | if (Type.isNullable(match)) { |
| 53 | return Optional.none(); |
| 54 | } |
| 55 | |
| 56 | const result: Record<string, string> = {}; |
| 57 | if (Type.isObject(match.groups)) { |
| 58 | for (const name of paramNames) { |
| 59 | if (Type.isString(match.groups[name])) { |
| 60 | result[name] = match.groups[name]; |
| 61 | } |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | return Optional.some(result); |
| 66 | }; |
| 67 | |
| 68 | return matcher; |
| 69 | }; |
no test coverage detected
searching dependent graphs…