(url, patterns)
| 691 | } |
| 692 | |
| 693 | function matchOneOfPatterns(url, patterns) { |
| 694 | if (!patterns?.length) return false; |
| 695 | for (let pattern of patterns) { |
| 696 | const regex = new RegExp( |
| 697 | "^" + |
| 698 | pattern |
| 699 | .split("*") |
| 700 | .map((part) => part.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")) |
| 701 | .join(".*") |
| 702 | .replace("http://", "http(s?)://") |
| 703 | ); |
| 704 | if (regex.test(url)) return pattern; |
| 705 | } |
| 706 | return false; |
| 707 | } |
no test coverage detected