| 1757 | return re; |
| 1758 | } |
| 1759 | makeRe() { |
| 1760 | if (this.regexp || this.regexp === false) |
| 1761 | return this.regexp; |
| 1762 | const set = this.set; |
| 1763 | if (!set.length) { |
| 1764 | this.regexp = false; |
| 1765 | return this.regexp; |
| 1766 | } |
| 1767 | const options = this.options; |
| 1768 | const twoStar = options.noglobstar ? star : options.dot ? twoStarDot : twoStarNoDot; |
| 1769 | const flags = new Set(options.nocase ? ["i"] : []); |
| 1770 | let re = set.map((pattern) => { |
| 1771 | const pp = pattern.map((p) => { |
| 1772 | if (p instanceof RegExp) { |
| 1773 | for (const f of p.flags.split("")) |
| 1774 | flags.add(f); |
| 1775 | } |
| 1776 | return typeof p === "string" ? regExpEscape(p) : p === exports.GLOBSTAR ? exports.GLOBSTAR : p._src; |
| 1777 | }); |
| 1778 | pp.forEach((p, i) => { |
| 1779 | const next = pp[i + 1]; |
| 1780 | const prev = pp[i - 1]; |
| 1781 | if (p !== exports.GLOBSTAR || prev === exports.GLOBSTAR) { |
| 1782 | return; |
| 1783 | } |
| 1784 | if (prev === void 0) { |
| 1785 | if (next !== void 0 && next !== exports.GLOBSTAR) { |
| 1786 | pp[i + 1] = "(?:\\/|" + twoStar + "\\/)?" + next; |
| 1787 | } else { |
| 1788 | pp[i] = twoStar; |
| 1789 | } |
| 1790 | } else if (next === void 0) { |
| 1791 | pp[i - 1] = prev + "(?:\\/|\\/" + twoStar + ")?"; |
| 1792 | } else if (next !== exports.GLOBSTAR) { |
| 1793 | pp[i - 1] = prev + "(?:\\/|\\/" + twoStar + "\\/)" + next; |
| 1794 | pp[i + 1] = exports.GLOBSTAR; |
| 1795 | } |
| 1796 | }); |
| 1797 | const filtered = pp.filter((p) => p !== exports.GLOBSTAR); |
| 1798 | if (this.partial && filtered.length >= 1) { |
| 1799 | const prefixes = []; |
| 1800 | for (let i = 1; i <= filtered.length; i++) { |
| 1801 | prefixes.push(filtered.slice(0, i).join("/")); |
| 1802 | } |
| 1803 | return "(?:" + prefixes.join("|") + ")"; |
| 1804 | } |
| 1805 | return filtered.join("/"); |
| 1806 | }).join("|"); |
| 1807 | const [open, close] = set.length > 1 ? ["(?:", ")"] : ["", ""]; |
| 1808 | re = "^" + open + re + close + "$"; |
| 1809 | if (this.partial) { |
| 1810 | re = "^(?:\\/|" + open + re.slice(1, -1) + close + ")$"; |
| 1811 | } |
| 1812 | if (this.negate) |
| 1813 | re = "^(?!" + re + ").+$"; |
| 1814 | try { |
| 1815 | this.regexp = new RegExp(re, [...flags].join("")); |
| 1816 | } catch { |