How to use _resolveHref method in Cypress

Best JavaScript code snippet using cypress

f6078781a05fe1bcb0902d23dbbb2662c8d200b3.b2520e98b352390f2961.js

Source:f6078781a05fe1bcb0902d23dbbb2662c8d200b3.b2520e98b352390f2961.js Github

copy

Full Screen

...1748                                t.abrupt("return", !1)1749                              );1750                            case 45:1751                              if (1752                                ((l = this._resolveHref(l, _)).pathname !== y &&1753                                  ((y = l.pathname),1754                                  (n = (0, p.formatWithValidation)(l))),1755                                (y = y1756                                  ? (0, c.removePathTrailingSlash)(O(y))1757                                  : y),1758                                this.urlIsNew(f) || u || (r = "replaceState"),1759                                (T = (0, c.removePathTrailingSlash)(y)),1760                                (I = i.shallow),1761                                (D = void 0 !== I && I),1762                                (M = a),1763                                (M = (0, m.default)(1764                                  (0, v.parseRelativeUrl)(a).pathname,1765                                  _,1766                                  "",1767                                  j,1768                                  w,1769                                  function (e) {1770                                    return te._resolveHref(1771                                      {1772                                        pathname: e,1773                                      },1774                                      _1775                                    ).pathname;1776                                  }1777                                )) !== a &&1778                                  ((N = (0, c.removePathTrailingSlash)(1779                                    this._resolveHref(1780                                      Object.assign({}, l, {1781                                        pathname: M,1782                                      }),1783                                      _,1784                                      !11785                                    ).pathname1786                                  )),1787                                  _.includes(N) &&1788                                    ((T = N),1789                                    (y = N),1790                                    (l.pathname = y),1791                                    (n = (0, p.formatWithValidation)(l)))),1792                                (M = P(O(M), this.locale)),1793                                !(0, d.isDynamicRoute)(T))1794                              ) {1795                                t.next = 69;1796                                break;1797                              }1798                              if (1799                                ((U = (0, v.parseRelativeUrl)(M)),1800                                (W = U.pathname),1801                                (q = (0, b.getRouteRegex)(T)),1802                                (F = (0, g.getRouteMatcher)(q)(W)),1803                                (G = (H = T === W) ? k(T, W, w) : {}),1804                                F && (!H || G.result))1805                              ) {1806                                t.next = 68;1807                                break;1808                              }1809                              if (1810                                !(1811                                  (B = Object.keys(q.groups).filter(function (1812                                    e1813                                  ) {1814                                    return !w[e];1815                                  })).length > 01816                                )1817                              ) {1818                                t.next = 66;1819                                break;1820                              }1821                              throw new Error(1822                                (H1823                                  ? "The provided `href` ("1824                                      .concat(1825                                        n,1826                                        ") value is missing query values ("1827                                      )1828                                      .concat(1829                                        B.join(", "),1830                                        ") to be interpolated properly. "1831                                      )1832                                  : "The provided `as` value ("1833                                      .concat(1834                                        W,1835                                        ") is incompatible with the `href` value ("1836                                      )1837                                      .concat(T, "). ")) +1838                                  "Read more: https://err.sh/vercel/next.js/".concat(1839                                    H1840                                      ? "href-interpolation-failed"1841                                      : "incompatible-href-as"1842                                  )1843                              );1844                            case 66:1845                              t.next = 69;1846                              break;1847                            case 68:1848                              H1849                                ? (a = (0, p.formatWithValidation)(1850                                    Object.assign({}, U, {1851                                      pathname: G.result,1852                                      query: A(w, G.params),1853                                    })1854                                  ))1855                                : Object.assign(w, F);1856                            case 69:1857                              return (1858                                e.events.emit("routeChangeStart", a),1859                                (t.prev = 70),1860                                (t.next = 73),1861                                this.getRouteInfo(T, y, w, a, D)1862                              );1863                            case 73:1864                              if (1865                                ((V = t.sent),1866                                (z = V.error),1867                                ($ = V.props),1868                                (K = V.__N_SSG),1869                                (Q = V.__N_SSP),1870                                !(1871                                  (K || Q) &&1872                                  $ &&1873                                  $.pageProps &&1874                                  $.pageProps.__N_REDIRECT1875                                ))1876                              ) {1877                                t.next = 85;1878                                break;1879                              }1880                              if (1881                                !(Y = $.pageProps.__N_REDIRECT).startsWith("/")1882                              ) {1883                                t.next = 83;1884                                break;1885                              }1886                              if (1887                                ((J = (0, v.parseRelativeUrl)(Y)),1888                                this._resolveHref(J, _, !1),1889                                !_.includes(J.pathname))1890                              ) {1891                                t.next = 83;1892                                break;1893                              }1894                              return (1895                                (X = C(this, Y, Y)),1896                                (Z = X.url),1897                                (ee = X.as),1898                                t.abrupt("return", this.change(r, Z, ee, i))1899                              );1900                            case 83:1901                              return (1902                                (window.location.href = Y),1903                                t.abrupt("return", new Promise(function () {}))1904                              );1905                            case 85:1906                              return (1907                                e.events.emit("beforeHistoryChange", a),1908                                this.changeState(r, n, a, i),1909                                (t.next = 90),1910                                this.set(T, y, w, f, V).catch(function (e) {1911                                  if (!e.cancelled) throw e;1912                                  z = z || e;1913                                })1914                              );1915                            case 90:1916                              if (!z) {1917                                t.next = 93;1918                                break;1919                              }1920                              throw (1921                                (e.events.emit("routeChangeError", z, f), z)1922                              );1923                            case 93:1924                              return (1925                                e.events.emit("routeChangeComplete", a),1926                                t.abrupt("return", !0)1927                              );1928                            case 99:1929                              if (1930                                ((t.prev = 99),1931                                (t.t1 = t.catch(70)),1932                                !t.t1.cancelled)1933                              ) {1934                                t.next = 103;1935                                break;1936                              }1937                              return t.abrupt("return", !1);1938                            case 103:1939                              throw t.t1;1940                            case 104:1941                            case "end":1942                              return t.stop();1943                          }1944                      },1945                      t,1946                      this,1947                      [1948                        [31, 41],1949                        [70, 99],1950                      ]1951                    );1952                  })1953                );1954                return function (e, r, n, o) {1955                  return t.apply(this, arguments);1956                };1957              })(),1958            },1959            {1960              key: "changeState",1961              value: function (e, t, r) {1962                var n =1963                  arguments.length > 3 && void 0 !== arguments[3]1964                    ? arguments[3]1965                    : {};1966                ("pushState" === e && (0, p.getURL)() === r) ||1967                  ((this._shallow = n.shallow),1968                  window.history[e](1969                    {1970                      url: t,1971                      as: r,1972                      options: n,1973                      __N: !0,1974                    },1975                    "",1976                    r1977                  ));1978              },1979            },1980            {1981              key: "handleRouteInfoError",1982              value: (function () {1983                var t = a(1984                  o.mark(function t(r, n, a, i, u) {1985                    var c, f, l, p, h, d, v, y;1986                    return o.wrap(1987                      function (t) {1988                        for (;;)1989                          switch ((t.prev = t.next)) {1990                            case 0:1991                              if (!r.cancelled) {1992                                t.next = 2;1993                                break;1994                              }1995                              throw r;1996                            case 2:1997                              if (!(0, s.isAssetError)(r) && !u) {1998                                t.next = 6;1999                                break;2000                              }2001                              throw (2002                                (e.events.emit("routeChangeError", r, i),2003                                (window.location.href = i),2004                                _())2005                              );2006                            case 6:2007                              if (2008                                ((t.prev = 6),2009                                !(p = "SSG Data NOT_FOUND" === r.message))2010                              ) {2011                                t.next = 24;2012                                break;2013                              }2014                              return (2015                                (t.prev = 9),2016                                (t.next = 12),2017                                this.fetchComponent("/404")2018                              );2019                            case 12:2020                              if (2021                                ((d = t.sent),2022                                (c = d.page),2023                                (f = d.styleSheets),2024                                !(h = d.mod) || !h.__N_SSG)2025                              ) {2026                                t.next = 20;2027                                break;2028                              }2029                              return (2030                                (t.next = 19),2031                                this._getStaticData(2032                                  this.pageLoader.getDataHref(2033                                    "/404",2034                                    "/404",2035                                    !0,2036                                    this.locale2037                                  )2038                                )2039                              );2040                            case 19:2041                              l = t.sent;2042                            case 20:2043                              t.next = 24;2044                              break;2045                            case 22:2046                              (t.prev = 22), (t.t0 = t.catch(9));2047                            case 24:2048                              if (2049                                "undefined" !== typeof c &&2050                                "undefined" !== typeof f2051                              ) {2052                                t.next = 31;2053                                break;2054                              }2055                              return (2056                                (t.next = 28), this.fetchComponent("/_error")2057                              );2058                            case 28:2059                              (v = t.sent), (c = v.page), (f = v.styleSheets);2060                            case 31:2061                              if (2062                                (y = {2063                                  props: l,2064                                  Component: c,2065                                  styleSheets: f,2066                                  err: p ? void 0 : r,2067                                  error: p ? void 0 : r,2068                                }).props2069                              ) {2070                                t.next = 43;2071                                break;2072                              }2073                              return (2074                                (t.prev = 33),2075                                (t.next = 36),2076                                this.getInitialProps(c, {2077                                  err: r,2078                                  pathname: n,2079                                  query: a,2080                                })2081                              );2082                            case 36:2083                              (y.props = t.sent), (t.next = 43);2084                              break;2085                            case 39:2086                              (t.prev = 39),2087                                (t.t1 = t.catch(33)),2088                                console.error(2089                                  "Error in error page `getInitialProps`: ",2090                                  t.t12091                                ),2092                                (y.props = {});2093                            case 43:2094                              return t.abrupt("return", y);2095                            case 46:2096                              return (2097                                (t.prev = 46),2098                                (t.t2 = t.catch(6)),2099                                t.abrupt(2100                                  "return",2101                                  this.handleRouteInfoError(t.t2, n, a, i, !0)2102                                )2103                              );2104                            case 49:2105                            case "end":2106                              return t.stop();2107                          }2108                      },2109                      t,2110                      this,2111                      [2112                        [6, 46],2113                        [9, 22],2114                        [33, 39],2115                      ]2116                    );2117                  })2118                );2119                return function (e, r, n, o, a) {2120                  return t.apply(this, arguments);2121                };2122              })(),2123            },2124            {2125              key: "getRouteInfo",2126              value: (function () {2127                var e = a(2128                  o.mark(function e(t, r, n, a) {2129                    var i,2130                      u,2131                      c,2132                      s,2133                      f,2134                      l,2135                      h,2136                      d,2137                      v,2138                      y = this,2139                      m = arguments;2140                    return o.wrap(2141                      function (e) {2142                        for (;;)2143                          switch ((e.prev = e.next)) {2144                            case 0:2145                              if (2146                                ((i = m.length > 4 && void 0 !== m[4] && m[4]),2147                                (e.prev = 1),2148                                (u = this.components[t]),2149                                !i || !u || this.route !== t)2150                              ) {2151                                e.next = 5;2152                                break;2153                              }2154                              return e.abrupt("return", u);2155                            case 5:2156                              if (!(c = u && "initial" in u ? void 0 : u)) {2157                                e.next = 10;2158                                break;2159                              }2160                              (e.t0 = c), (e.next = 13);2161                              break;2162                            case 10:2163                              return (2164                                (e.next = 12),2165                                this.fetchComponent(t).then(function (e) {2166                                  return {2167                                    Component: e.page,2168                                    styleSheets: e.styleSheets,2169                                    __N_SSG: e.mod.__N_SSG,2170                                    __N_SSP: e.mod.__N_SSP,2171                                  };2172                                })2173                              );2174                            case 12:2175                              e.t0 = e.sent;2176                            case 13:2177                              (s = e.t0),2178                                (f = s.Component),2179                                (l = s.__N_SSG),2180                                (h = s.__N_SSP),2181                                (e.next = 19);2182                              break;2183                            case 19:2184                              return (2185                                (l || h) &&2186                                  (d = this.pageLoader.getDataHref(2187                                    (0, p.formatWithValidation)({2188                                      pathname: r,2189                                      query: n,2190                                    }),2191                                    O(a),2192                                    l,2193                                    this.locale2194                                  )),2195                                (e.next = 22),2196                                this._getData(function () {2197                                  return l2198                                    ? y._getStaticData(d)2199                                    : h2200                                    ? y._getServerData(d)2201                                    : y.getInitialProps(f, {2202                                        pathname: r,2203                                        query: n,2204                                        asPath: a,2205                                      });2206                                })2207                              );2208                            case 22:2209                              return (2210                                (v = e.sent),2211                                (s.props = v),2212                                (this.components[t] = s),2213                                e.abrupt("return", s)2214                              );2215                            case 28:2216                              return (2217                                (e.prev = 28),2218                                (e.t1 = e.catch(1)),2219                                e.abrupt(2220                                  "return",2221                                  this.handleRouteInfoError(e.t1, r, n, a)2222                                )2223                              );2224                            case 31:2225                            case "end":2226                              return e.stop();2227                          }2228                      },2229                      e,2230                      this,2231                      [[1, 28]]2232                    );2233                  })2234                );2235                return function (t, r, n, o) {2236                  return e.apply(this, arguments);2237                };2238              })(),2239            },2240            {2241              key: "set",2242              value: function (e, t, r, n, o) {2243                return (2244                  (this.isFallback = !1),2245                  (this.route = e),2246                  (this.pathname = t),2247                  (this.query = r),2248                  (this.asPath = n),2249                  this.notify(o)2250                );2251              },2252            },2253            {2254              key: "beforePopState",2255              value: function (e) {2256                this._bps = e;2257              },2258            },2259            {2260              key: "onlyAHashChange",2261              value: function (e) {2262                if (!this.asPath) return !1;2263                var t = this.asPath.split("#"),2264                  r = n(t, 2),2265                  o = r[0],2266                  a = r[1],2267                  i = e.split("#"),2268                  u = n(i, 2),2269                  c = u[0],2270                  s = u[1];2271                return !(!s || o !== c || a !== s) || (o === c && a !== s);2272              },2273            },2274            {2275              key: "scrollToHash",2276              value: function (e) {2277                var t = e.split("#"),2278                  r = n(t, 2)[1];2279                if ("" !== r) {2280                  var o = document.getElementById(r);2281                  if (o) o.scrollIntoView();2282                  else {2283                    var a = document.getElementsByName(r)[0];2284                    a && a.scrollIntoView();2285                  }2286                } else window.scrollTo(0, 0);2287              },2288            },2289            {2290              key: "urlIsNew",2291              value: function (e) {2292                return this.asPath !== e;2293              },2294            },2295            {2296              key: "_resolveHref",2297              value: function (e, t) {2298                var r =2299                    !(arguments.length > 2 && void 0 !== arguments[2]) ||2300                    arguments[2],2301                  n = e.pathname,2302                  o = (0, c.removePathTrailingSlash)(2303                    (0, f.denormalizePagePath)(r ? O(n) : n)2304                  );2305                return (2306                  "/404" === o ||2307                    "/_error" === o ||2308                    t.includes(o) ||2309                    t.some(function (t) {2310                      if (2311                        (0, d.isDynamicRoute)(t) &&2312                        (0, b.getRouteRegex)(t).re.test(o)2313                      )2314                        return (e.pathname = r ? E(t) : t), !0;2315                    }),2316                  e2317                );2318              },2319            },2320            {2321              key: "prefetch",2322              value: (function () {2323                var e = a(2324                  o.mark(function e(t) {2325                    var r,2326                      n,2327                      a,2328                      i,2329                      u,2330                      s,2331                      f = this,2332                      l = arguments;2333                    return o.wrap(2334                      function (e) {2335                        for (;;)2336                          switch ((e.prev = e.next)) {2337                            case 0:2338                              return (2339                                (r =2340                                  l.length > 1 && void 0 !== l[1] ? l[1] : t),2341                                (n =2342                                  l.length > 2 && void 0 !== l[2] ? l[2] : {}),2343                                (a = (0, v.parseRelativeUrl)(t)),2344                                (i = a.pathname),2345                                (e.next = 7),2346                                this.pageLoader.getPageList()2347                              );2348                            case 7:2349                              (u = e.sent),2350                                (a = this._resolveHref(a, u, !1)).pathname !==2351                                  i &&2352                                  ((i = a.pathname),2353                                  (t = (0, p.formatWithValidation)(a))),2354                                (e.next = 12);2355                              break;2356                            case 12:2357                              return (2358                                (s = (0, c.removePathTrailingSlash)(i)),2359                                (e.next = 15),2360                                Promise.all([2361                                  this.pageLoader._isSsg(t).then(function (e) {2362                                    return (2363                                      !!e &&2364                                      f._getStaticData(
...

Full Screen

Full Screen

commons.3a488244d0ef345263db.js

Source:commons.3a488244d0ef345263db.js Github

copy

Full Screen

...1141                                e.abrupt('return', !1)1142                              );1143                            case 50:1144                              if (1145                                ((b = this._resolveHref(b, A)).pathname !== C &&1146                                  ((C = b.pathname),1147                                  (o = (0, h.formatWithValidation)(b))),1148                                (C = C1149                                  ? (0, c.removePathTrailingSlash)(E(C))1150                                  : C),1151                                this.urlIsNew(w) || f || (r = 'replaceState'),1152                                (M = (0, c.removePathTrailingSlash)(C)),1153                                (N = a),1154                                R(a))1155                              ) {1156                                e.next = 62;1157                                break;1158                              }1159                              e.next = 60;1160                              break;1161                            case 60:1162                              return (1163                                (window.location.href = a),1164                                e.abrupt('return', !1)1165                              );1166                            case 62:1167                              if (1168                                ((N = x(E(N), this.locale)),1169                                !(0, p.isDynamicRoute)(M))1170                              ) {1171                                e.next = 78;1172                                break;1173                              }1174                              if (1175                                ((U = (0, d.parseRelativeUrl)(N)),1176                                (W = U.pathname),1177                                (F = (0, m.getRouteRegex)(M)),1178                                (q = (0, y.getRouteMatcher)(F)(W)),1179                                (G = (B = M === W) ? L(M, W, j) : {}),1180                                q && (!B || G.result))1181                              ) {1182                                e.next = 77;1183                                break;1184                              }1185                              if (1186                                !(1187                                  (H = Object.keys(F.groups).filter(function (1188                                    t1189                                  ) {1190                                    return !j[t];1191                                  })).length > 01192                                )1193                              ) {1194                                e.next = 75;1195                                break;1196                              }1197                              throw new Error(1198                                (B1199                                  ? 'The provided `href` ('1200                                      .concat(1201                                        o,1202                                        ') value is missing query values ('1203                                      )1204                                      .concat(1205                                        H.join(', '),1206                                        ') to be interpolated properly. '1207                                      )1208                                  : 'The provided `as` value ('1209                                      .concat(1210                                        W,1211                                        ') is incompatible with the `href` value ('1212                                      )1213                                      .concat(M, '). ')) +1214                                  'Read more: https://err.sh/vercel/next.js/'.concat(1215                                    B1216                                      ? 'href-interpolation-failed'1217                                      : 'incompatible-href-as'1218                                  )1219                              );1220                            case 75:1221                              e.next = 78;1222                              break;1223                            case 77:1224                              B1225                                ? (a = (0, h.formatWithValidation)(1226                                    Object.assign({}, U, {1227                                      pathname: G.result,1228                                      query: O(j, G.params),1229                                    })1230                                  ))1231                                : Object.assign(j, q);1232                            case 78:1233                              return (1234                                t.events.emit('routeChangeStart', a, g),1235                                (e.prev = 79),1236                                (e.next = 82),1237                                this.getRouteInfo(1238                                  M,1239                                  C,1240                                  j,1241                                  k(_(N, this.locale)),1242                                  g1243                                )1244                              );1245                            case 82:1246                              if (1247                                ((V = e.sent),1248                                (X = (z = V).error),1249                                (J = z.props),1250                                ($ = z.__N_SSG),1251                                (Y = z.__N_SSP),1252                                (!$ && !Y) || !J)1253                              ) {1254                                e.next = 108;1255                                break;1256                              }1257                              if (!J.pageProps || !J.pageProps.__N_REDIRECT) {1258                                e.next = 95;1259                                break;1260                              }1261                              if (1262                                !(Q = J.pageProps.__N_REDIRECT).startsWith('/')1263                              ) {1264                                e.next = 93;1265                                break;1266                              }1267                              if (1268                                ((Z = (0, d.parseRelativeUrl)(Q)),1269                                this._resolveHref(Z, A, !1),1270                                !A.includes(Z.pathname))1271                              ) {1272                                e.next = 93;1273                                break;1274                              }1275                              return (1276                                (K = T(this, Q, Q)),1277                                (tt = K.url),1278                                (et = K.as),1279                                e.abrupt('return', this.change(r, tt, et, i))1280                              );1281                            case 93:1282                              return (1283                                (window.location.href = Q),1284                                e.abrupt('return', new Promise(function () {}))1285                              );1286                            case 95:1287                              if (J.notFound !== I) {1288                                e.next = 108;1289                                break;1290                              }1291                              return (1292                                (e.prev = 96),1293                                (e.next = 99),1294                                this.fetchComponent('/404')1295                              );1296                            case 99:1297                              (rt = '/404'), (e.next = 105);1298                              break;1299                            case 102:1300                              (e.prev = 102),1301                                (e.t1 = e.catch(96)),1302                                (rt = '/_error');1303                            case 105:1304                              return (1305                                (e.next = 107),1306                                this.getRouteInfo(rt, rt, j, a, { shallow: !1 })1307                              );1308                            case 107:1309                              V = e.sent;1310                            case 108:1311                              return (1312                                t.events.emit('beforeHistoryChange', a, g),1313                                this.changeState(r, o, a, i),1314                                (e.next = 113),1315                                this.set(1316                                  M,1317                                  C,1318                                  j,1319                                  w,1320                                  V,1321                                  u || (i.scroll ? { x: 0, y: 0 } : null)1322                                ).catch(function (t) {1323                                  if (!t.cancelled) throw t;1324                                  X = X || t;1325                                })1326                              );1327                            case 113:1328                              if (!X) {1329                                e.next = 116;1330                                break;1331                              }1332                              throw (1333                                (t.events.emit('routeChangeError', X, w, g), X)1334                              );1335                            case 116:1336                              return (1337                                t.events.emit('routeChangeComplete', a, g),1338                                e.abrupt('return', !0)1339                              );1340                            case 121:1341                              if (1342                                ((e.prev = 121),1343                                (e.t2 = e.catch(79)),1344                                !e.t2.cancelled)1345                              ) {1346                                e.next = 125;1347                                break;1348                              }1349                              return e.abrupt('return', !1);1350                            case 125:1351                              throw e.t2;1352                            case 126:1353                            case 'end':1354                              return e.stop();1355                          }1356                      },1357                      e,1358                      this,1359                      [1360                        [36, 46],1361                        [79, 121],1362                        [96, 102],1363                      ]1364                    );1365                  })1366                );1367                return function (t, r, n, o, a) {1368                  return e.apply(this, arguments);1369                };1370              })(),1371            },1372            {1373              key: 'changeState',1374              value: function (t, e, r) {1375                var n =1376                  arguments.length > 3 && void 0 !== arguments[3]1377                    ? arguments[3]1378                    : {};1379                ('pushState' === t && (0, h.getURL)() === r) ||1380                  ((this._shallow = n.shallow),1381                  window.history[t](1382                    {1383                      url: e,1384                      as: r,1385                      options: n,1386                      __N: !0,1387                      idx: (this._idx =1388                        'pushState' !== t ? this._idx : this._idx + 1),1389                    },1390                    '',1391                    r1392                  ));1393              },1394            },1395            {1396              key: 'handleRouteInfoError',1397              value: (function () {1398                var e = o(1399                  n.mark(function e(r, o, a, i, u, c) {1400                    var l, f, h, p;1401                    return n.wrap(1402                      function (e) {1403                        for (;;)1404                          switch ((e.prev = e.next)) {1405                            case 0:1406                              if (!r.cancelled) {1407                                e.next = 2;1408                                break;1409                              }1410                              throw r;1411                            case 2:1412                              if (!(0, s.isAssetError)(r) && !c) {1413                                e.next = 6;1414                                break;1415                              }1416                              throw (1417                                (t.events.emit('routeChangeError', r, i, u),1418                                (window.location.href = i),1419                                b())1420                              );1421                            case 6:1422                              if (1423                                ((e.prev = 6),1424                                'undefined' !== typeof l &&1425                                  'undefined' !== typeof f)1426                              ) {1427                                e.next = 14;1428                                break;1429                              }1430                              return (1431                                (e.next = 11), this.fetchComponent('/_error')1432                              );1433                            case 11:1434                              (h = e.sent), (l = h.page), (f = h.styleSheets);1435                            case 14:1436                              if (1437                                (p = {1438                                  props: undefined,1439                                  Component: l,1440                                  styleSheets: f,1441                                  err: r,1442                                  error: r,1443                                }).props1444                              ) {1445                                e.next = 26;1446                                break;1447                              }1448                              return (1449                                (e.prev = 16),1450                                (e.next = 19),1451                                this.getInitialProps(l, {1452                                  err: r,1453                                  pathname: o,1454                                  query: a,1455                                })1456                              );1457                            case 19:1458                              (p.props = e.sent), (e.next = 26);1459                              break;1460                            case 22:1461                              (e.prev = 22),1462                                (e.t0 = e.catch(16)),1463                                console.error(1464                                  'Error in error page `getInitialProps`: ',1465                                  e.t01466                                ),1467                                (p.props = {});1468                            case 26:1469                              return e.abrupt('return', p);1470                            case 29:1471                              return (1472                                (e.prev = 29),1473                                (e.t1 = e.catch(6)),1474                                e.abrupt(1475                                  'return',1476                                  this.handleRouteInfoError(1477                                    e.t1,1478                                    o,1479                                    a,1480                                    i,1481                                    u,1482                                    !01483                                  )1484                                )1485                              );1486                            case 32:1487                            case 'end':1488                              return e.stop();1489                          }1490                      },1491                      e,1492                      this,1493                      [1494                        [6, 29],1495                        [16, 22],1496                      ]1497                    );1498                  })1499                );1500                return function (t, r, n, o, a, i) {1501                  return e.apply(this, arguments);1502                };1503              })(),1504            },1505            {1506              key: 'getRouteInfo',1507              value: (function () {1508                var t = o(1509                  n.mark(function t(e, r, o, a, i) {1510                    var u,1511                      c,1512                      s,1513                      l,1514                      f,1515                      p,1516                      d,1517                      v,1518                      y = this;1519                    return n.wrap(1520                      function (t) {1521                        for (;;)1522                          switch ((t.prev = t.next)) {1523                            case 0:1524                              if (1525                                ((t.prev = 0),1526                                (u = this.components[e]),1527                                !i.shallow || !u || this.route !== e)1528                              ) {1529                                t.next = 4;1530                                break;1531                              }1532                              return t.abrupt('return', u);1533                            case 4:1534                              if (!(c = u && 'initial' in u ? void 0 : u)) {1535                                t.next = 9;1536                                break;1537                              }1538                              (t.t0 = c), (t.next = 12);1539                              break;1540                            case 9:1541                              return (1542                                (t.next = 11),1543                                this.fetchComponent(e).then(function (t) {1544                                  return {1545                                    Component: t.page,1546                                    styleSheets: t.styleSheets,1547                                    __N_SSG: t.mod.__N_SSG,1548                                    __N_SSP: t.mod.__N_SSP,1549                                  };1550                                })1551                              );1552                            case 11:1553                              t.t0 = t.sent;1554                            case 12:1555                              (s = t.t0),1556                                (l = s.Component),1557                                (f = s.__N_SSG),1558                                (p = s.__N_SSP),1559                                (t.next = 18);1560                              break;1561                            case 18:1562                              return (1563                                (f || p) &&1564                                  (d = this.pageLoader.getDataHref(1565                                    (0, h.formatWithValidation)({1566                                      pathname: r,1567                                      query: o,1568                                    }),1569                                    E(a),1570                                    f,1571                                    this.locale1572                                  )),1573                                (t.next = 21),1574                                this._getData(function () {1575                                  return f1576                                    ? y._getStaticData(d)1577                                    : p1578                                    ? y._getServerData(d)1579                                    : y.getInitialProps(l, {1580                                        pathname: r,1581                                        query: o,1582                                        asPath: a,1583                                      });1584                                })1585                              );1586                            case 21:1587                              return (1588                                (v = t.sent),1589                                (s.props = v),1590                                (this.components[e] = s),1591                                t.abrupt('return', s)1592                              );1593                            case 27:1594                              return (1595                                (t.prev = 27),1596                                (t.t1 = t.catch(0)),1597                                t.abrupt(1598                                  'return',1599                                  this.handleRouteInfoError(t.t1, r, o, a, i)1600                                )1601                              );1602                            case 30:1603                            case 'end':1604                              return t.stop();1605                          }1606                      },1607                      t,1608                      this,1609                      [[0, 27]]1610                    );1611                  })1612                );1613                return function (e, r, n, o, a) {1614                  return t.apply(this, arguments);1615                };1616              })(),1617            },1618            {1619              key: 'set',1620              value: function (t, e, r, n, o, a) {1621                return (1622                  (this.isFallback = !1),1623                  (this.route = t),1624                  (this.pathname = e),1625                  (this.query = r),1626                  (this.asPath = n),1627                  this.notify(o, a)1628                );1629              },1630            },1631            {1632              key: 'beforePopState',1633              value: function (t) {1634                this._bps = t;1635              },1636            },1637            {1638              key: 'onlyAHashChange',1639              value: function (t) {1640                if (!this.asPath) return !1;1641                var e = this.asPath.split('#'),1642                  r = u(e, 2),1643                  n = r[0],1644                  o = r[1],1645                  a = t.split('#'),1646                  i = u(a, 2),1647                  c = i[0],1648                  s = i[1];1649                return !(!s || n !== c || o !== s) || (n === c && o !== s);1650              },1651            },1652            {1653              key: 'scrollToHash',1654              value: function (t) {1655                var e = t.split('#'),1656                  r = u(e, 2)[1];1657                if ('' !== r) {1658                  var n = document.getElementById(r);1659                  if (n) n.scrollIntoView();1660                  else {1661                    var o = document.getElementsByName(r)[0];1662                    o && o.scrollIntoView();1663                  }1664                } else window.scrollTo(0, 0);1665              },1666            },1667            {1668              key: 'urlIsNew',1669              value: function (t) {1670                return this.asPath !== t;1671              },1672            },1673            {1674              key: '_resolveHref',1675              value: function (t, e) {1676                var r =1677                    !(arguments.length > 2 && void 0 !== arguments[2]) ||1678                    arguments[2],1679                  n = t.pathname,1680                  o = (0, c.removePathTrailingSlash)(1681                    (0, l.denormalizePagePath)(r ? E(n) : n)1682                  );1683                return (1684                  '/404' === o ||1685                    '/_error' === o ||1686                    (e.includes(o) ||1687                      e.some(function (e) {1688                        if (1689                          (0, p.isDynamicRoute)(e) &&1690                          (0, m.getRouteRegex)(e).re.test(o)1691                        )1692                          return (t.pathname = r ? k(e) : e), !0;1693                      }),1694                    (t.pathname = (0, c.removePathTrailingSlash)(t.pathname))),1695                  t1696                );1697              },1698            },1699            {1700              key: 'prefetch',1701              value: (function () {1702                var t = o(1703                  n.mark(function t(e) {1704                    var r,1705                      o,1706                      a,1707                      i,1708                      u,1709                      s,1710                      l = this,1711                      f = arguments;1712                    return n.wrap(1713                      function (t) {1714                        for (;;)1715                          switch ((t.prev = t.next)) {1716                            case 0:1717                              return (1718                                (r =1719                                  f.length > 1 && void 0 !== f[1] ? f[1] : e),1720                                (o =1721                                  f.length > 2 && void 0 !== f[2] ? f[2] : {}),1722                                (a = (0, d.parseRelativeUrl)(e)),1723                                (i = a.pathname),1724                                (t.next = 7),1725                                this.pageLoader.getPageList()1726                              );1727                            case 7:1728                              (u = t.sent),1729                                (a = this._resolveHref(a, u, !1)).pathname !==1730                                  i &&1731                                  ((i = a.pathname),1732                                  (e = (0, h.formatWithValidation)(a))),1733                                (t.next = 12);1734                              break;1735                            case 12:1736                              return (1737                                (s = (0, c.removePathTrailingSlash)(i)),1738                                (t.next = 15),1739                                Promise.all([1740                                  this.pageLoader._isSsg(e).then(function (t) {1741                                    return (1742                                      !!t &&1743                                      l._getStaticData(...

Full Screen

Full Screen

commons.b90d1dd8c8f9098b3db8.js

Source:commons.b90d1dd8c8f9098b3db8.js Github

copy

Full Screen

...736                                l.__rewrites,737                                (d = (0, p.parseRelativeUrl)(n)),738                                (g = (m = d).pathname),739                                (b = m.query),740                                (d = this._resolveHref(d, s)).pathname !== g &&741                                  ((g = d.pathname),742                                  (n = (0, h.formatWithValidation)(d))),743                                (g = g744                                  ? (0, c.removePathTrailingSlash)(P(g))745                                  : g),746                                this.urlIsNew(u) || (r = "replaceState"),747                                (S = (0, c.removePathTrailingSlash)(g)),748                                (E = i.shallow),749                                (O = void 0 !== E && E),750                                (j = _(P((j = a)), this.locale)),751                                !(0, f.isDynamicRoute)(S))752                              ) {753                                e.next = 50;754                                break;755                              }756                              if (757                                ((C = (0, p.parseRelativeUrl)(j)),758                                (I = C.pathname),759                                (A = (0, y.getRouteRegex)(S)),760                                (T = (0, v.getRouteMatcher)(A)(I)),761                                (U = (N = S === I) ? R(S, I, b) : {}),762                                T && (!N || U.result))763                              ) {764                                e.next = 49;765                                break;766                              }767                              if (768                                !(769                                  (D = Object.keys(A.groups).filter(function (770                                    t771                                  ) {772                                    return !b[t];773                                  })).length > 0774                                )775                              ) {776                                e.next = 47;777                                break;778                              }779                              throw new Error(780                                (N781                                  ? "The provided `href` ("782                                      .concat(783                                        n,784                                        ") value is missing query values ("785                                      )786                                      .concat(787                                        D.join(", "),788                                        ") to be interpolated properly. "789                                      )790                                  : "The provided `as` value ("791                                      .concat(792                                        I,793                                        ") is incompatible with the `href` value ("794                                      )795                                      .concat(S, "). ")) +796                                  "Read more: https://err.sh/vercel/next.js/".concat(797                                    N798                                      ? "href-interpolation-failed"799                                      : "incompatible-href-as"800                                  )801                              );802                            case 47:803                              e.next = 50;804                              break;805                            case 49:806                              N807                                ? (a = (0, h.formatWithValidation)(808                                    Object.assign({}, C, {809                                      pathname: U.result,810                                      query: L(b, U.params),811                                    })812                                  ))813                                : Object.assign(b, T);814                            case 50:815                              return (816                                t.events.emit("routeChangeStart", a),817                                (e.prev = 51),818                                (e.next = 54),819                                this.getRouteInfo(S, g, b, a, O)820                              );821                            case 54:822                              if (823                                ((W = e.sent),824                                (M = W.error),825                                (q = W.props),826                                (G = W.__N_SSG),827                                (F = W.__N_SSP),828                                !(829                                  (G || F) &&830                                  q &&831                                  q.pageProps &&832                                  q.pageProps.__N_REDIRECT833                                ))834                              ) {835                                e.next = 65;836                                break;837                              }838                              if (839                                !(B = q.pageProps.__N_REDIRECT).startsWith("/")840                              ) {841                                e.next = 63;842                                break;843                              }844                              if (845                                ((V = (0, p.parseRelativeUrl)(B)),846                                this._resolveHref(V, s),847                                !s.includes(V.pathname))848                              ) {849                                e.next = 63;850                                break;851                              }852                              return e.abrupt(853                                "return",854                                this.change("replaceState", B, B, i)855                              );856                            case 63:857                              return (858                                (window.location.href = B),859                                e.abrupt("return", new Promise(function () {}))860                              );861                            case 65:862                              return (863                                t.events.emit("beforeHistoryChange", a),864                                this.changeState(865                                  r,866                                  n,867                                  w(a, this.locale, this.defaultLocale),868                                  i869                                ),870                                (e.next = 70),871                                this.set(S, g, b, u, W).catch(function (t) {872                                  if (!t.cancelled) throw t;873                                  M = M || t;874                                })875                              );876                            case 70:877                              if (!M) {878                                e.next = 73;879                                break;880                              }881                              throw (882                                (t.events.emit("routeChangeError", M, u), M)883                              );884                            case 73:885                              return (886                                t.events.emit("routeChangeComplete", a),887                                e.abrupt("return", !0)888                              );889                            case 78:890                              if (891                                ((e.prev = 78),892                                (e.t0 = e.catch(51)),893                                !e.t0.cancelled)894                              ) {895                                e.next = 82;896                                break;897                              }898                              return e.abrupt("return", !1);899                            case 82:900                              throw e.t0;901                            case 83:902                            case "end":903                              return e.stop();904                          }905                      },906                      e,907                      this,908                      [[51, 78]]909                    );910                  })911                );912                return function (t, r, n, o) {913                  return e.apply(this, arguments);914                };915              })(),916            },917            {918              key: "changeState",919              value: function (t, e, r) {920                var n =921                  arguments.length > 3 && void 0 !== arguments[3]922                    ? arguments[3]923                    : {};924                ("pushState" === t && (0, h.getURL)() === r) ||925                  ((this._shallow = n.shallow),926                  window.history[t](927                    { url: e, as: r, options: n, __N: !0 },928                    "",929                    r930                  ));931              },932            },933            {934              key: "handleRouteInfoError",935              value: (function () {936                var e = a(937                  o.mark(function e(r, n, a, i, u) {938                    var c, s, l, h;939                    return o.wrap(940                      function (e) {941                        for (;;)942                          switch ((e.prev = e.next)) {943                            case 0:944                              if (!r.cancelled) {945                                e.next = 2;946                                break;947                              }948                              throw r;949                            case 2:950                              if (!(O in r) && !u) {951                                e.next = 6;952                                break;953                              }954                              throw (955                                (t.events.emit("routeChangeError", r, i),956                                (window.location.href = i),957                                b())958                              );959                            case 6:960                              return (961                                (e.prev = 6),962                                (e.next = 9),963                                this.fetchComponent("/_error")964                              );965                            case 9:966                              return (967                                (c = e.sent),968                                (s = c.page),969                                (l = c.styleSheets),970                                (h = {971                                  Component: s,972                                  styleSheets: l,973                                  err: r,974                                  error: r,975                                }),976                                (e.prev = 13),977                                (e.next = 16),978                                this.getInitialProps(s, {979                                  err: r,980                                  pathname: n,981                                  query: a,982                                })983                              );984                            case 16:985                              (h.props = e.sent), (e.next = 23);986                              break;987                            case 19:988                              (e.prev = 19),989                                (e.t0 = e.catch(13)),990                                console.error(991                                  "Error in error page `getInitialProps`: ",992                                  e.t0993                                ),994                                (h.props = {});995                            case 23:996                              return e.abrupt("return", h);997                            case 26:998                              return (999                                (e.prev = 26),1000                                (e.t1 = e.catch(6)),1001                                e.abrupt(1002                                  "return",1003                                  this.handleRouteInfoError(e.t1, n, a, i, !0)1004                                )1005                              );1006                            case 29:1007                            case "end":1008                              return e.stop();1009                          }1010                      },1011                      e,1012                      this,1013                      [1014                        [6, 26],1015                        [13, 19],1016                      ]1017                    );1018                  })1019                );1020                return function (t, r, n, o, a) {1021                  return e.apply(this, arguments);1022                };1023              })(),1024            },1025            {1026              key: "getRouteInfo",1027              value: (function () {1028                var t = a(1029                  o.mark(function t(e, r, n, a) {1030                    var i,1031                      u,1032                      c,1033                      s,1034                      l,1035                      f,1036                      p,1037                      d,1038                      v = this,1039                      y = arguments;1040                    return o.wrap(1041                      function (t) {1042                        for (;;)1043                          switch ((t.prev = t.next)) {1044                            case 0:1045                              if (1046                                ((i = y.length > 4 && void 0 !== y[4] && y[4]),1047                                (t.prev = 1),1048                                (u = this.components[e]),1049                                !i || !u || this.route !== e)1050                              ) {1051                                t.next = 5;1052                                break;1053                              }1054                              return t.abrupt("return", u);1055                            case 5:1056                              if (!u) {1057                                t.next = 9;1058                                break;1059                              }1060                              (t.t0 = u), (t.next = 12);1061                              break;1062                            case 9:1063                              return (1064                                (t.next = 11),1065                                this.fetchComponent(e).then(function (t) {1066                                  return {1067                                    Component: t.page,1068                                    styleSheets: t.styleSheets,1069                                    __N_SSG: t.mod.__N_SSG,1070                                    __N_SSP: t.mod.__N_SSP,1071                                  };1072                                })1073                              );1074                            case 11:1075                              t.t0 = t.sent;1076                            case 12:1077                              (c = t.t0),1078                                (s = c.Component),1079                                (l = c.__N_SSG),1080                                (f = c.__N_SSP),1081                                (t.next = 18);1082                              break;1083                            case 18:1084                              return (1085                                (l || f) &&1086                                  (p = this.pageLoader.getDataHref(1087                                    (0, h.formatWithValidation)({1088                                      pathname: r,1089                                      query: n,1090                                    }),1091                                    P(a),1092                                    l,1093                                    this.locale,1094                                    this.defaultLocale1095                                  )),1096                                (t.next = 21),1097                                this._getData(function () {1098                                  return l1099                                    ? v._getStaticData(p)1100                                    : f1101                                    ? v._getServerData(p)1102                                    : v.getInitialProps(s, {1103                                        pathname: r,1104                                        query: n,1105                                        asPath: a,1106                                      });1107                                })1108                              );1109                            case 21:1110                              return (1111                                (d = t.sent),1112                                (c.props = d),1113                                (this.components[e] = c),1114                                t.abrupt("return", c)1115                              );1116                            case 27:1117                              return (1118                                (t.prev = 27),1119                                (t.t1 = t.catch(1)),1120                                t.abrupt(1121                                  "return",1122                                  this.handleRouteInfoError(t.t1, r, n, a)1123                                )1124                              );1125                            case 30:1126                            case "end":1127                              return t.stop();1128                          }1129                      },1130                      t,1131                      this,1132                      [[1, 27]]1133                    );1134                  })1135                );1136                return function (e, r, n, o) {1137                  return t.apply(this, arguments);1138                };1139              })(),1140            },1141            {1142              key: "set",1143              value: function (t, e, r, n, o) {1144                return (1145                  (this.isFallback = !1),1146                  (this.route = t),1147                  (this.pathname = e),1148                  (this.query = r),1149                  (this.asPath = n),1150                  this.notify(o)1151                );1152              },1153            },1154            {1155              key: "beforePopState",1156              value: function (t) {1157                this._bps = t;1158              },1159            },1160            {1161              key: "onlyAHashChange",1162              value: function (t) {1163                if (!this.asPath) return !1;1164                var e = this.asPath.split("#"),1165                  r = n(e, 2),1166                  o = r[0],1167                  a = r[1],1168                  i = t.split("#"),1169                  u = n(i, 2),1170                  c = u[0],1171                  s = u[1];1172                return !(!s || o !== c || a !== s) || (o === c && a !== s);1173              },1174            },1175            {1176              key: "scrollToHash",1177              value: function (t) {1178                var e = t.split("#"),1179                  r = n(e, 2)[1];1180                if ("" !== r) {1181                  var o = document.getElementById(r);1182                  if (o) o.scrollIntoView();1183                  else {1184                    var a = document.getElementsByName(r)[0];1185                    a && a.scrollIntoView();1186                  }1187                } else window.scrollTo(0, 0);1188              },1189            },1190            {1191              key: "urlIsNew",1192              value: function (t) {1193                return this.asPath !== t;1194              },1195            },1196            {1197              key: "_resolveHref",1198              value: function (t, e) {1199                var r =1200                    !(arguments.length > 2 && void 0 !== arguments[2]) ||1201                    arguments[2],1202                  n = t.pathname,1203                  o = (0, c.removePathTrailingSlash)(1204                    (0, s.denormalizePagePath)(r ? P(n) : n)1205                  );1206                return (1207                  "/404" === o ||1208                    "/_error" === o ||1209                    e.includes(o) ||1210                    e.some(function (e) {1211                      if (1212                        (0, f.isDynamicRoute)(e) &&1213                        (0, y.getRouteRegex)(e).re.test(o)1214                      )1215                        return (t.pathname = r ? S(e) : e), !0;1216                    }),1217                  t1218                );1219              },1220            },1221            {1222              key: "prefetch",1223              value: (function () {1224                var t = a(1225                  o.mark(function t(e) {1226                    var r,1227                      n,1228                      a,1229                      i,1230                      u,1231                      s,1232                      l = arguments;1233                    return o.wrap(1234                      function (t) {1235                        for (;;)1236                          switch ((t.prev = t.next)) {1237                            case 0:1238                              return (1239                                (r =1240                                  l.length > 1 && void 0 !== l[1] ? l[1] : e),1241                                (n =1242                                  l.length > 2 && void 0 !== l[2] ? l[2] : {}),1243                                (a = (0, p.parseRelativeUrl)(e)),1244                                (i = a.pathname),1245                                (t.next = 6),1246                                this.pageLoader.getPageList()1247                              );1248                            case 6:1249                              (u = t.sent),1250                                (a = this._resolveHref(a, u)).pathname !== i &&1251                                  ((i = a.pathname),1252                                  (e = (0, h.formatWithValidation)(a))),1253                                (t.next = 11);1254                              break;1255                            case 11:1256                              return (1257                                (s = (0, c.removePathTrailingSlash)(i)),1258                                (t.next = 14),1259                                Promise.all([1260                                  this.pageLoader.prefetchData(1261                                    e,1262                                    r,1263                                    this.locale,1264                                    this.defaultLocale...

Full Screen

Full Screen

f6078781a05fe1bcb0902d23dbbb2662c8d200b3.f11984b14d38c71e2959.js

Source:f6078781a05fe1bcb0902d23dbbb2662c8d200b3.f11984b14d38c71e2959.js Github

copy

Full Screen

...1085                                t.abrupt("return", !1)1086                              );1087                            case 46:1088                              if (1089                                ((m = this._resolveHref(m, j)).pathname !== b &&1090                                  ((b = m.pathname),1091                                  (n = (0, h.formatWithValidation)(m))),1092                                (b = b1093                                  ? (0, s.removePathTrailingSlash)(k(b))1094                                  : b),1095                                this.urlIsNew(p) || u || (r = "replaceState"),1096                                (M = (0, s.removePathTrailingSlash)(b)),1097                                (D = P(k((D = a)), this.locale)),1098                                !(0, d.isDynamicRoute)(M))1099                              ) {1100                                t.next = 69;1101                                break;1102                              }1103                              if (1104                                ((T = (0, v.parseRelativeUrl)(D)),1105                                (A = T.pathname),1106                                (U = (0, g.getRouteRegex)(M)),1107                                (N = (0, y.getRouteMatcher)(U)(A)),1108                                (q = (W = M === A) ? E(M, A, O) : {}),1109                                N && (!W || q.result))1110                              ) {1111                                t.next = 68;1112                                break;1113                              }1114                              if (1115                                !(1116                                  (F = Object.keys(U.groups).filter(function (1117                                    e1118                                  ) {1119                                    return !O[e];1120                                  })).length > 01121                                )1122                              ) {1123                                t.next = 66;1124                                break;1125                              }1126                              throw new Error(1127                                (W1128                                  ? "The provided `href` ("1129                                      .concat(1130                                        n,1131                                        ") value is missing query values ("1132                                      )1133                                      .concat(1134                                        F.join(", "),1135                                        ") to be interpolated properly. "1136                                      )1137                                  : "The provided `as` value ("1138                                      .concat(1139                                        A,1140                                        ") is incompatible with the `href` value ("1141                                      )1142                                      .concat(M, "). ")) +1143                                  "Read more: https://err.sh/vercel/next.js/".concat(1144                                    W1145                                      ? "href-interpolation-failed"1146                                      : "incompatible-href-as"1147                                  )1148                              );1149                            case 66:1150                              t.next = 69;1151                              break;1152                            case 68:1153                              W1154                                ? (a = (0, h.formatWithValidation)(1155                                    Object.assign({}, T, {1156                                      pathname: q.result,1157                                      query: C(O, q.params),1158                                    })1159                                  ))1160                                : Object.assign(O, N);1161                            case 69:1162                              return (1163                                e.events.emit("routeChangeStart", a, f),1164                                (t.prev = 70),1165                                (t.next = 73),1166                                this.getRouteInfo(M, b, O, a, f)1167                              );1168                            case 73:1169                              if (1170                                ((B = t.sent),1171                                (H = B.error),1172                                (G = B.props),1173                                (V = B.__N_SSG),1174                                (z = B.__N_SSP),1175                                !(1176                                  (V || z) &&1177                                  G &&1178                                  G.pageProps &&1179                                  G.pageProps.__N_REDIRECT1180                                ))1181                              ) {1182                                t.next = 85;1183                                break;1184                              }1185                              if (1186                                !(J = G.pageProps.__N_REDIRECT).startsWith("/")1187                              ) {1188                                t.next = 83;1189                                break;1190                              }1191                              if (1192                                ((X = (0, v.parseRelativeUrl)(J)),1193                                this._resolveHref(X, j, !1),1194                                !j.includes(X.pathname))1195                              ) {1196                                t.next = 83;1197                                break;1198                              }1199                              return (1200                                (Y = L(this, J, J)),1201                                ($ = Y.url),1202                                (Q = Y.as),1203                                t.abrupt("return", this.change(r, $, Q, i))1204                              );1205                            case 83:1206                              return (1207                                (window.location.href = J),1208                                t.abrupt("return", new Promise(function () {}))1209                              );1210                            case 85:1211                              return (1212                                e.events.emit("beforeHistoryChange", a, f),1213                                this.changeState(r, n, a, i),1214                                (t.next = 90),1215                                this.set(M, b, O, p, B).catch(function (e) {1216                                  if (!e.cancelled) throw e;1217                                  H = H || e;1218                                })1219                              );1220                            case 90:1221                              if (!H) {1222                                t.next = 93;1223                                break;1224                              }1225                              throw (1226                                (e.events.emit("routeChangeError", H, p, f), H)1227                              );1228                            case 93:1229                              return (1230                                e.events.emit("routeChangeComplete", a, f),1231                                t.abrupt("return", !0)1232                              );1233                            case 99:1234                              if (1235                                ((t.prev = 99),1236                                (t.t1 = t.catch(70)),1237                                !t.t1.cancelled)1238                              ) {1239                                t.next = 103;1240                                break;1241                              }1242                              return t.abrupt("return", !1);1243                            case 103:1244                              throw t.t1;1245                            case 104:1246                            case "end":1247                              return t.stop();1248                          }1249                      },1250                      t,1251                      this,1252                      [1253                        [32, 42],1254                        [70, 99],1255                      ]1256                    );1257                  })1258                );1259                return function (e, r, n, o) {1260                  return t.apply(this, arguments);1261                };1262              })(),1263            },1264            {1265              key: "changeState",1266              value: function (e, t, r) {1267                var n =1268                  arguments.length > 3 && void 0 !== arguments[3]1269                    ? arguments[3]1270                    : {};1271                ("pushState" === e && (0, h.getURL)() === r) ||1272                  ((this._shallow = n.shallow),1273                  window.history[e](1274                    { url: t, as: r, options: n, __N: !0 },1275                    "",1276                    r1277                  ));1278              },1279            },1280            {1281              key: "handleRouteInfoError",1282              value: (function () {1283                var t = a(1284                  o.mark(function t(r, n, a, i, u, s) {1285                    var l, f, h, p, d, v, m, y;1286                    return o.wrap(1287                      function (t) {1288                        for (;;)1289                          switch ((t.prev = t.next)) {1290                            case 0:1291                              if (!r.cancelled) {1292                                t.next = 2;1293                                break;1294                              }1295                              throw r;1296                            case 2:1297                              if (!(0, c.isAssetError)(r) && !s) {1298                                t.next = 6;1299                                break;1300                              }1301                              throw (1302                                (e.events.emit("routeChangeError", r, i, u),1303                                (window.location.href = i),1304                                b())1305                              );1306                            case 6:1307                              if (((t.prev = 6), !(p = r.message === j))) {1308                                t.next = 24;1309                                break;1310                              }1311                              return (1312                                (t.prev = 9),1313                                (t.next = 12),1314                                this.fetchComponent("/404")1315                              );1316                            case 12:1317                              if (1318                                ((v = t.sent),1319                                (l = v.page),1320                                (f = v.styleSheets),1321                                !(d = v.mod) || !d.__N_SSG)1322                              ) {1323                                t.next = 20;1324                                break;1325                              }1326                              return (1327                                (t.next = 19),1328                                this._getStaticData(1329                                  this.pageLoader.getDataHref(1330                                    "/404",1331                                    "/404",1332                                    !0,1333                                    this.locale1334                                  )1335                                )1336                              );1337                            case 19:1338                              h = t.sent;1339                            case 20:1340                              t.next = 24;1341                              break;1342                            case 22:1343                              (t.prev = 22), (t.t0 = t.catch(9));1344                            case 24:1345                              if (1346                                "undefined" !== typeof l &&1347                                "undefined" !== typeof f1348                              ) {1349                                t.next = 31;1350                                break;1351                              }1352                              return (1353                                (t.next = 28), this.fetchComponent("/_error")1354                              );1355                            case 28:1356                              (m = t.sent), (l = m.page), (f = m.styleSheets);1357                            case 31:1358                              if (1359                                (y = {1360                                  props: h,1361                                  Component: l,1362                                  styleSheets: f,1363                                  err: p ? void 0 : r,1364                                  error: p ? void 0 : r,1365                                }).props1366                              ) {1367                                t.next = 43;1368                                break;1369                              }1370                              return (1371                                (t.prev = 33),1372                                (t.next = 36),1373                                this.getInitialProps(l, {1374                                  err: r,1375                                  pathname: n,1376                                  query: a,1377                                })1378                              );1379                            case 36:1380                              (y.props = t.sent), (t.next = 43);1381                              break;1382                            case 39:1383                              (t.prev = 39),1384                                (t.t1 = t.catch(33)),1385                                console.error(1386                                  "Error in error page `getInitialProps`: ",1387                                  t.t11388                                ),1389                                (y.props = {});1390                            case 43:1391                              return t.abrupt("return", y);1392                            case 46:1393                              return (1394                                (t.prev = 46),1395                                (t.t2 = t.catch(6)),1396                                t.abrupt(1397                                  "return",1398                                  this.handleRouteInfoError(1399                                    t.t2,1400                                    n,1401                                    a,1402                                    i,1403                                    u,1404                                    !01405                                  )1406                                )1407                              );1408                            case 49:1409                            case "end":1410                              return t.stop();1411                          }1412                      },1413                      t,1414                      this,1415                      [1416                        [6, 46],1417                        [9, 22],1418                        [33, 39],1419                      ]1420                    );1421                  })1422                );1423                return function (e, r, n, o, a, i) {1424                  return t.apply(this, arguments);1425                };1426              })(),1427            },1428            {1429              key: "getRouteInfo",1430              value: (function () {1431                var e = a(1432                  o.mark(function e(t, r, n, a, i) {1433                    var u,1434                      s,1435                      c,1436                      l,1437                      f,1438                      p,1439                      d,1440                      v,1441                      m = this;1442                    return o.wrap(1443                      function (e) {1444                        for (;;)1445                          switch ((e.prev = e.next)) {1446                            case 0:1447                              if (1448                                ((e.prev = 0),1449                                (u = this.components[t]),1450                                !i.shallow || !u || this.route !== t)1451                              ) {1452                                e.next = 4;1453                                break;1454                              }1455                              return e.abrupt("return", u);1456                            case 4:1457                              if (!(s = u && "initial" in u ? void 0 : u)) {1458                                e.next = 9;1459                                break;1460                              }1461                              (e.t0 = s), (e.next = 12);1462                              break;1463                            case 9:1464                              return (1465                                (e.next = 11),1466                                this.fetchComponent(t).then(function (e) {1467                                  return {1468                                    Component: e.page,1469                                    styleSheets: e.styleSheets,1470                                    __N_SSG: e.mod.__N_SSG,1471                                    __N_SSP: e.mod.__N_SSP,1472                                  };1473                                })1474                              );1475                            case 11:1476                              e.t0 = e.sent;1477                            case 12:1478                              (c = e.t0),1479                                (l = c.Component),1480                                (f = c.__N_SSG),1481                                (p = c.__N_SSP),1482                                (e.next = 18);1483                              break;1484                            case 18:1485                              return (1486                                (f || p) &&1487                                  (d = this.pageLoader.getDataHref(1488                                    (0, h.formatWithValidation)({1489                                      pathname: r,1490                                      query: n,1491                                    }),1492                                    k(a),1493                                    f,1494                                    this.locale1495                                  )),1496                                (e.next = 21),1497                                this._getData(function () {1498                                  return f1499                                    ? m._getStaticData(d)1500                                    : p1501                                    ? m._getServerData(d)1502                                    : m.getInitialProps(l, {1503                                        pathname: r,1504                                        query: n,1505                                        asPath: a,1506                                      });1507                                })1508                              );1509                            case 21:1510                              return (1511                                (v = e.sent),1512                                (c.props = v),1513                                (this.components[t] = c),1514                                e.abrupt("return", c)1515                              );1516                            case 27:1517                              return (1518                                (e.prev = 27),1519                                (e.t1 = e.catch(0)),1520                                e.abrupt(1521                                  "return",1522                                  this.handleRouteInfoError(e.t1, r, n, a, i)1523                                )1524                              );1525                            case 30:1526                            case "end":1527                              return e.stop();1528                          }1529                      },1530                      e,1531                      this,1532                      [[0, 27]]1533                    );1534                  })1535                );1536                return function (t, r, n, o, a) {1537                  return e.apply(this, arguments);1538                };1539              })(),1540            },1541            {1542              key: "set",1543              value: function (e, t, r, n, o) {1544                return (1545                  (this.isFallback = !1),1546                  (this.route = e),1547                  (this.pathname = t),1548                  (this.query = r),1549                  (this.asPath = n),1550                  this.notify(o)1551                );1552              },1553            },1554            {1555              key: "beforePopState",1556              value: function (e) {1557                this._bps = e;1558              },1559            },1560            {1561              key: "onlyAHashChange",1562              value: function (e) {1563                if (!this.asPath) return !1;1564                var t = this.asPath.split("#"),1565                  r = n(t, 2),1566                  o = r[0],1567                  a = r[1],1568                  i = e.split("#"),1569                  u = n(i, 2),1570                  s = u[0],1571                  c = u[1];1572                return !(!c || o !== s || a !== c) || (o === s && a !== c);1573              },1574            },1575            {1576              key: "scrollToHash",1577              value: function (e) {1578                var t = e.split("#"),1579                  r = n(t, 2)[1];1580                if ("" !== r) {1581                  var o = document.getElementById(r);1582                  if (o) o.scrollIntoView();1583                  else {1584                    var a = document.getElementsByName(r)[0];1585                    a && a.scrollIntoView();1586                  }1587                } else window.scrollTo(0, 0);1588              },1589            },1590            {1591              key: "urlIsNew",1592              value: function (e) {1593                return this.asPath !== e;1594              },1595            },1596            {1597              key: "_resolveHref",1598              value: function (e, t) {1599                var r =1600                    !(arguments.length > 2 && void 0 !== arguments[2]) ||1601                    arguments[2],1602                  n = e.pathname,1603                  o = (0, s.removePathTrailingSlash)(1604                    (0, l.denormalizePagePath)(r ? k(n) : n)1605                  );1606                return (1607                  "/404" === o ||1608                    "/_error" === o ||1609                    (t.includes(o) ||1610                      t.some(function (t) {1611                        if (1612                          (0, d.isDynamicRoute)(t) &&1613                          (0, g.getRouteRegex)(t).re.test(o)1614                        )1615                          return (e.pathname = r ? x(t) : t), !0;1616                      }),1617                    (e.pathname = (0, s.removePathTrailingSlash)(e.pathname))),1618                  e1619                );1620              },1621            },1622            {1623              key: "prefetch",1624              value: (function () {1625                var e = a(1626                  o.mark(function e(t) {1627                    var r,1628                      n,1629                      a,1630                      i,1631                      u,1632                      c,1633                      l = this,1634                      f = arguments;1635                    return o.wrap(1636                      function (e) {1637                        for (;;)1638                          switch ((e.prev = e.next)) {1639                            case 0:1640                              return (1641                                (r =1642                                  f.length > 1 && void 0 !== f[1] ? f[1] : t),1643                                (n =1644                                  f.length > 2 && void 0 !== f[2] ? f[2] : {}),1645                                (a = (0, v.parseRelativeUrl)(t)),1646                                (i = a.pathname),1647                                (e.next = 7),1648                                this.pageLoader.getPageList()1649                              );1650                            case 7:1651                              (u = e.sent),1652                                (a = this._resolveHref(a, u, !1)).pathname !==1653                                  i &&1654                                  ((i = a.pathname),1655                                  (t = (0, h.formatWithValidation)(a))),1656                                (e.next = 12);1657                              break;1658                            case 12:1659                              return (1660                                (c = (0, s.removePathTrailingSlash)(i)),1661                                (e.next = 15),1662                                Promise.all([1663                                  this.pageLoader._isSsg(t).then(function (e) {1664                                    return (1665                                      !!e &&1666                                      l._getStaticData(...

Full Screen

Full Screen

cfa4664881a301d5662214878bd68057f0abd7a3.0ac42f82057789ac213b.js

Source:cfa4664881a301d5662214878bd68057f0abd7a3.0ac42f82057789ac213b.js Github

copy

Full Screen

...488                                        return e.next = 19, this.pageLoader.getPageList();489                                    case 19:490                                        return s = e.sent, e.next = 22, this.pageLoader.promisedBuildManifest;491                                    case 22:492                                        if (l = e.sent, l.__rewrites, d = (0, p.parseRelativeUrl)(n), m = (g = d).pathname, b = g.query, (d = this._resolveHref(d, s)).pathname !== m && (m = d.pathname, n = (0, f.formatWithValidation)(d)), m = m ? (0, c.removePathTrailingSlash)(P(m)) : m, this.urlIsNew(u) || (r = "replaceState"), S = (0, c.removePathTrailingSlash)(m), O = i.shallow, L = void 0 !== O && O, j = _(P(j = a), this.locale), !(0, h.isDynamicRoute)(S)) {493                                            e.next = 50;494                                            break495                                        }496                                        if (C = (0, p.parseRelativeUrl)(j), A = C.pathname, I = (0, y.getRouteRegex)(S), T = (0, v.getRouteMatcher)(I)(A), N = (U = S === A) ? R(S, A, b) : {}, T && (!U || N.result)) {497                                            e.next = 49;498                                            break499                                        }500                                        if (!((q = Object.keys(I.groups).filter((function(t) {501                                                return !b[t]502                                            }))).length > 0)) {503                                            e.next = 47;504                                            break505                                        }506                                        throw new Error((U ? "The provided `href` (".concat(n, ") value is missing query values (").concat(q.join(", "), ") to be interpolated properly. ") : "The provided `as` value (".concat(A, ") is incompatible with the `href` value (").concat(S, "). ")) + "Read more: https://err.sh/vercel/next.js/".concat(U ? "href-interpolation-failed" : "incompatible-href-as"));507                                    case 47:508                                        e.next = 50;509                                        break;510                                    case 49:511                                        U ? a = (0, f.formatWithValidation)(Object.assign({}, C, {512                                            pathname: N.result,513                                            query: E(b, N.params)514                                        })) : Object.assign(b, T);515                                    case 50:516                                        return t.events.emit("routeChangeStart", a), e.prev = 51, e.next = 54, this.getRouteInfo(S, m, b, a, L);517                                    case 54:518                                        if (D = e.sent, W = D.error, M = D.props, G = D.__N_SSG, F = D.__N_SSP, !((G || F) && M && M.pageProps && M.pageProps.__N_REDIRECT)) {519                                            e.next = 65;520                                            break521                                        }522                                        if (!(H = M.pageProps.__N_REDIRECT).startsWith("/")) {523                                            e.next = 63;524                                            break525                                        }526                                        if (V = (0, p.parseRelativeUrl)(H), this._resolveHref(V, s), !s.includes(V.pathname)) {527                                            e.next = 63;528                                            break529                                        }530                                        return e.abrupt("return", this.change("replaceState", H, H, i));531                                    case 63:532                                        return window.location.href = H, e.abrupt("return", new Promise((function() {})));533                                    case 65:534                                        return t.events.emit("beforeHistoryChange", a), this.changeState(r, n, w(a, this.locale, this.defaultLocale), i), e.next = 70, this.set(S, m, b, u, D).catch((function(t) {535                                            if (!t.cancelled) throw t;536                                            W = W || t537                                        }));538                                    case 70:539                                        if (!W) {540                                            e.next = 73;541                                            break542                                        }543                                        throw t.events.emit("routeChangeError", W, u), W;544                                    case 73:545                                        return t.events.emit("routeChangeComplete", a), e.abrupt("return", !0);546                                    case 78:547                                        if (e.prev = 78, e.t0 = e.catch(51), !e.t0.cancelled) {548                                            e.next = 82;549                                            break550                                        }551                                        return e.abrupt("return", !1);552                                    case 82:553                                        throw e.t0;554                                    case 83:555                                    case "end":556                                        return e.stop()557                                }558                            }), e, this, [559                                [51, 78]560                            ])561                        })));562                        return function(t, r, n, o) {563                            return e.apply(this, arguments)564                        }565                    }()566                }, {567                    key: "changeState",568                    value: function(t, e, r) {569                        var n = arguments.length > 3 && void 0 !== arguments[3] ? arguments[3] : {};570                        "pushState" === t && (0, f.getURL)() === r || (this._shallow = n.shallow, window.history[t]({571                            url: e,572                            as: r,573                            options: n,574                            __N: !0575                        }, "", r))576                    }577                }, {578                    key: "handleRouteInfoError",579                    value: function() {580                        var e = a(o.mark((function e(r, n, a, i, u) {581                            var c, s, l, f;582                            return o.wrap((function(e) {583                                for (;;) switch (e.prev = e.next) {584                                    case 0:585                                        if (!r.cancelled) {586                                            e.next = 2;587                                            break588                                        }589                                        throw r;590                                    case 2:591                                        if (!(L in r) && !u) {592                                            e.next = 6;593                                            break594                                        }595                                        throw t.events.emit("routeChangeError", r, i), window.location.href = i, b();596                                    case 6:597                                        return e.prev = 6, e.next = 9, this.fetchComponent("/_error");598                                    case 9:599                                        return c = e.sent, s = c.page, l = c.styleSheets, f = {600                                            Component: s,601                                            styleSheets: l,602                                            err: r,603                                            error: r604                                        }, e.prev = 13, e.next = 16, this.getInitialProps(s, {605                                            err: r,606                                            pathname: n,607                                            query: a608                                        });609                                    case 16:610                                        f.props = e.sent, e.next = 23;611                                        break;612                                    case 19:613                                        e.prev = 19, e.t0 = e.catch(13), console.error("Error in error page `getInitialProps`: ", e.t0), f.props = {};614                                    case 23:615                                        return e.abrupt("return", f);616                                    case 26:617                                        return e.prev = 26, e.t1 = e.catch(6), e.abrupt("return", this.handleRouteInfoError(e.t1, n, a, i, !0));618                                    case 29:619                                    case "end":620                                        return e.stop()621                                }622                            }), e, this, [623                                [6, 26],624                                [13, 19]625                            ])626                        })));627                        return function(t, r, n, o, a) {628                            return e.apply(this, arguments)629                        }630                    }()631                }, {632                    key: "getRouteInfo",633                    value: function() {634                        var t = a(o.mark((function t(e, r, n, a) {635                            var i, u, c, s, l, h, p, d, v = this,636                                y = arguments;637                            return o.wrap((function(t) {638                                for (;;) switch (t.prev = t.next) {639                                    case 0:640                                        if (i = y.length > 4 && void 0 !== y[4] && y[4], t.prev = 1, u = this.components[e], !i || !u || this.route !== e) {641                                            t.next = 5;642                                            break643                                        }644                                        return t.abrupt("return", u);645                                    case 5:646                                        if (!u) {647                                            t.next = 9;648                                            break649                                        }650                                        t.t0 = u, t.next = 12;651                                        break;652                                    case 9:653                                        return t.next = 11, this.fetchComponent(e).then((function(t) {654                                            return {655                                                Component: t.page,656                                                styleSheets: t.styleSheets,657                                                __N_SSG: t.mod.__N_SSG,658                                                __N_SSP: t.mod.__N_SSP659                                            }660                                        }));661                                    case 11:662                                        t.t0 = t.sent;663                                    case 12:664                                        c = t.t0, s = c.Component, l = c.__N_SSG, h = c.__N_SSP, t.next = 18;665                                        break;666                                    case 18:667                                        return (l || h) && (p = this.pageLoader.getDataHref((0, f.formatWithValidation)({668                                            pathname: r,669                                            query: n670                                        }), P(a), l, this.locale, this.defaultLocale)), t.next = 21, this._getData((function() {671                                            return l ? v._getStaticData(p) : h ? v._getServerData(p) : v.getInitialProps(s, {672                                                pathname: r,673                                                query: n,674                                                asPath: a675                                            })676                                        }));677                                    case 21:678                                        return d = t.sent, c.props = d, this.components[e] = c, t.abrupt("return", c);679                                    case 27:680                                        return t.prev = 27, t.t1 = t.catch(1), t.abrupt("return", this.handleRouteInfoError(t.t1, r, n, a));681                                    case 30:682                                    case "end":683                                        return t.stop()684                                }685                            }), t, this, [686                                [1, 27]687                            ])688                        })));689                        return function(e, r, n, o) {690                            return t.apply(this, arguments)691                        }692                    }()693                }, {694                    key: "set",695                    value: function(t, e, r, n, o) {696                        return this.isFallback = !1, this.route = t, this.pathname = e, this.query = r, this.asPath = n, this.notify(o)697                    }698                }, {699                    key: "beforePopState",700                    value: function(t) {701                        this._bps = t702                    }703                }, {704                    key: "onlyAHashChange",705                    value: function(t) {706                        if (!this.asPath) return !1;707                        var e = this.asPath.split("#"),708                            r = n(e, 2),709                            o = r[0],710                            a = r[1],711                            i = t.split("#"),712                            u = n(i, 2),713                            c = u[0],714                            s = u[1];715                        return !(!s || o !== c || a !== s) || o === c && a !== s716                    }717                }, {718                    key: "scrollToHash",719                    value: function(t) {720                        var e = t.split("#"),721                            r = n(e, 2)[1];722                        if ("" !== r) {723                            var o = document.getElementById(r);724                            if (o) o.scrollIntoView();725                            else {726                                var a = document.getElementsByName(r)[0];727                                a && a.scrollIntoView()728                            }729                        } else window.scrollTo(0, 0)730                    }731                }, {732                    key: "urlIsNew",733                    value: function(t) {734                        return this.asPath !== t735                    }736                }, {737                    key: "_resolveHref",738                    value: function(t, e) {739                        var r = !(arguments.length > 2 && void 0 !== arguments[2]) || arguments[2],740                            n = t.pathname,741                            o = (0, c.removePathTrailingSlash)((0, s.denormalizePagePath)(r ? P(n) : n));742                        return "/404" === o || "/_error" === o || e.includes(o) || e.some((function(e) {743                            if ((0, h.isDynamicRoute)(e) && (0, y.getRouteRegex)(e).re.test(o)) return t.pathname = r ? S(e) : e, !0744                        })), t745                    }746                }, {747                    key: "prefetch",748                    value: function() {749                        var t = a(o.mark((function t(e) {750                            var r, n, a, i, u, s, l = arguments;751                            return o.wrap((function(t) {752                                for (;;) switch (t.prev = t.next) {753                                    case 0:754                                        return r = l.length > 1 && void 0 !== l[1] ? l[1] : e, n = l.length > 2 && void 0 !== l[2] ? l[2] : {}, a = (0, p.parseRelativeUrl)(e), i = a.pathname, t.next = 6, this.pageLoader.getPageList();755                                    case 6:756                                        u = t.sent, (a = this._resolveHref(a, u)).pathname !== i && (i = a.pathname, e = (0, f.formatWithValidation)(a)), t.next = 11;757                                        break;758                                    case 11:759                                        return s = (0, c.removePathTrailingSlash)(i), t.next = 14, Promise.all([this.pageLoader.prefetchData(e, r, this.locale, this.defaultLocale), this.pageLoader[n.priority ? "loadPage" : "prefetch"](s)]);760                                    case 14:761                                    case "end":762                                        return t.stop()763                                }764                            }), t, this)765                        })));766                        return function(e) {767                            return t.apply(this, arguments)768                        }769                    }()770                }, {...

Full Screen

Full Screen

f6078781a05fe1bcb0902d23dbbb2662c8d200b3.93753030cb95202614cb.js

Source:f6078781a05fe1bcb0902d23dbbb2662c8d200b3.93753030cb95202614cb.js Github

copy

Full Screen

...702                                        break;703                                    case 46:704                                        return t.prev = 46, t.t0 = t.catch(36), window.location.href = o, t.abrupt("return", !1);705                                    case 50:706                                        if ((x = this._resolveHref(x, D)).pathname !== L && (L = x.pathname, a = (0, h.formatWithValidation)(x)), L = L ? (0, u.removePathTrailingSlash)(S(L)) : L, this.urlIsNew(_) || f || (r = "replaceState"), M = (0, u.removePathTrailingSlash)(L), U = o, R(o)) {707                                            t.next = 62;708                                            break709                                        }710                                        t.next = 60;711                                        break;712                                    case 60:713                                        return window.location.href = o, t.abrupt("return", !1);714                                    case 62:715                                        if (U = w(S(U), this.locale), !(0, p.isDynamicRoute)(M)) {716                                            t.next = 78;717                                            break718                                        }719                                        if (N = (0, d.parseRelativeUrl)(U), W = N.pathname, q = (0, g.getRouteRegex)(M), F = (0, m.getRouteMatcher)(q)(W), G = (B = M === W) ? C(M, W, A) : {}, F && (!B || G.result)) {720                                            t.next = 77;721                                            break722                                        }723                                        if (!((H = Object.keys(q.groups).filter((function(e) {724                                                return !A[e]725                                            }))).length > 0)) {726                                            t.next = 75;727                                            break728                                        }729                                        throw new Error((B ? "The provided `href` (".concat(a, ") value is missing query values (").concat(H.join(", "), ") to be interpolated properly. ") : "The provided `as` value (".concat(W, ") is incompatible with the `href` value (").concat(M, "). ")) + "Read more: https://err.sh/vercel/next.js/".concat(B ? "href-interpolation-failed" : "incompatible-href-as"));730                                    case 75:731                                        t.next = 78;732                                        break;733                                    case 77:734                                        B ? o = (0, h.formatWithValidation)(Object.assign({}, N, {735                                            pathname: G.result,736                                            query: E(A, G.params)737                                        })) : Object.assign(A, F);738                                    case 78:739                                        return e.events.emit("routeChangeStart", o, y), t.prev = 79, t.next = 82, this.getRouteInfo(M, L, A, o, U, y);740                                    case 82:741                                        if (V = t.sent, z = (X = V).error, J = X.props, $ = X.__N_SSG, Q = X.__N_SSP, !$ && !Q || !J) {742                                            t.next = 108;743                                            break744                                        }745                                        if (!J.pageProps || !J.pageProps.__N_REDIRECT) {746                                            t.next = 95;747                                            break748                                        }749                                        if (!(Y = J.pageProps.__N_REDIRECT).startsWith("/")) {750                                            t.next = 93;751                                            break752                                        }753                                        if (Z = (0, d.parseRelativeUrl)(Y), this._resolveHref(Z, D, !1), !D.includes(Z.pathname)) {754                                            t.next = 93;755                                            break756                                        }757                                        return K = O(this, Y, Y), ee = K.url, te = K.as, t.abrupt("return", this.change(r, ee, te, i));758                                    case 93:759                                        return window.location.href = Y, t.abrupt("return", new Promise((function() {})));760                                    case 95:761                                        if (J.notFound !== T) {762                                            t.next = 108;763                                            break764                                        }765                                        return t.prev = 96, t.next = 99, this.fetchComponent("/404");766                                    case 99:767                                        re = "/404", t.next = 105;768                                        break;769                                    case 102:770                                        t.prev = 102, t.t1 = t.catch(96), re = "/_error";771                                    case 105:772                                        return t.next = 107, this.getRouteInfo(re, re, A, o, U, {773                                            shallow: !1774                                        });775                                    case 107:776                                        V = t.sent;777                                    case 108:778                                        return e.events.emit("beforeHistoryChange", o, y), this.changeState(r, a, o, i), ne = i.shallow && this.route === M, t.next = 114, this.set(M, L, A, _, V, s || (ne || !i.scroll ? null : {779                                            x: 0,780                                            y: 0781                                        })).catch((function(e) {782                                            if (!e.cancelled) throw e;783                                            z = z || e784                                        }));785                                    case 114:786                                        if (!z) {787                                            t.next = 117;788                                            break789                                        }790                                        throw e.events.emit("routeChangeError", z, _, y), z;791                                    case 117:792                                        return e.events.emit("routeChangeComplete", o, y), t.abrupt("return", !0);793                                    case 122:794                                        if (t.prev = 122, t.t2 = t.catch(79), !t.t2.cancelled) {795                                            t.next = 126;796                                            break797                                        }798                                        return t.abrupt("return", !1);799                                    case 126:800                                        throw t.t2;801                                    case 127:802                                    case "end":803                                        return t.stop()804                                }805                            }), t, this, [806                                [36, 46],807                                [79, 122],808                                [96, 102]809                            ])810                        })));811                        return function(e, r, n, a, o) {812                            return t.apply(this, arguments)813                        }814                    }()815                }, {816                    key: "changeState",817                    value: function(e, t, r) {818                        var n = arguments.length > 3 && void 0 !== arguments[3] ? arguments[3] : {};819                        "pushState" === e && (0, h.getURL)() === r || (this._shallow = n.shallow, window.history[e]({820                            url: t,821                            as: r,822                            options: n,823                            __N: !0,824                            idx: this._idx = "pushState" !== e ? this._idx : this._idx + 1825                        }, "", r))826                    }827                }, {828                    key: "handleRouteInfoError",829                    value: function() {830                        var t = a(n.mark((function t(r, a, o, i, s, u) {831                            var l, f, h, p;832                            return n.wrap((function(t) {833                                for (;;) switch (t.prev = t.next) {834                                    case 0:835                                        if (!r.cancelled) {836                                            t.next = 2;837                                            break838                                        }839                                        throw r;840                                    case 2:841                                        if (!(0, c.isAssetError)(r) && !u) {842                                            t.next = 6;843                                            break844                                        }845                                        throw e.events.emit("routeChangeError", r, i, s), window.location.href = i, _();846                                    case 6:847                                        if (t.prev = 6, "undefined" !== typeof l && "undefined" !== typeof f) {848                                            t.next = 14;849                                            break850                                        }851                                        return t.next = 11, this.fetchComponent("/_error");852                                    case 11:853                                        h = t.sent, l = h.page, f = h.styleSheets;854                                    case 14:855                                        if ((p = {856                                                props: undefined,857                                                Component: l,858                                                styleSheets: f,859                                                err: r,860                                                error: r861                                            }).props) {862                                            t.next = 26;863                                            break864                                        }865                                        return t.prev = 16, t.next = 19, this.getInitialProps(l, {866                                            err: r,867                                            pathname: a,868                                            query: o869                                        });870                                    case 19:871                                        p.props = t.sent, t.next = 26;872                                        break;873                                    case 22:874                                        t.prev = 22, t.t0 = t.catch(16), console.error("Error in error page `getInitialProps`: ", t.t0), p.props = {};875                                    case 26:876                                        return t.abrupt("return", p);877                                    case 29:878                                        return t.prev = 29, t.t1 = t.catch(6), t.abrupt("return", this.handleRouteInfoError(t.t1, a, o, i, s, !0));879                                    case 32:880                                    case "end":881                                        return t.stop()882                                }883                            }), t, this, [884                                [6, 29],885                                [16, 22]886                            ])887                        })));888                        return function(e, r, n, a, o, i) {889                            return t.apply(this, arguments)890                        }891                    }()892                }, {893                    key: "getRouteInfo",894                    value: function() {895                        var e = a(n.mark((function e(t, r, a, o, i, s) {896                            var u, c, l, f, p, d, v, m, g = this;897                            return n.wrap((function(e) {898                                for (;;) switch (e.prev = e.next) {899                                    case 0:900                                        if (e.prev = 0, u = this.components[t], !s.shallow || !u || this.route !== t) {901                                            e.next = 4;902                                            break903                                        }904                                        return e.abrupt("return", u);905                                    case 4:906                                        if (!(c = u && "initial" in u ? void 0 : u)) {907                                            e.next = 9;908                                            break909                                        }910                                        e.t0 = c, e.next = 12;911                                        break;912                                    case 9:913                                        return e.next = 11, this.fetchComponent(t).then((function(e) {914                                            return {915                                                Component: e.page,916                                                styleSheets: e.styleSheets,917                                                __N_SSG: e.mod.__N_SSG,918                                                __N_SSP: e.mod.__N_SSP919                                            }920                                        }));921                                    case 11:922                                        e.t0 = e.sent;923                                    case 12:924                                        l = e.t0, f = l.Component, p = l.__N_SSG, d = l.__N_SSP, e.next = 18;925                                        break;926                                    case 18:927                                        return (p || d) && (v = this.pageLoader.getDataHref((0, h.formatWithValidation)({928                                            pathname: r,929                                            query: a930                                        }), i, p, this.locale)), e.next = 21, this._getData((function() {931                                            return p ? g._getStaticData(v) : d ? g._getServerData(v) : g.getInitialProps(f, {932                                                pathname: r,933                                                query: a,934                                                asPath: o935                                            })936                                        }));937                                    case 21:938                                        return m = e.sent, l.props = m, this.components[t] = l, e.abrupt("return", l);939                                    case 27:940                                        return e.prev = 27, e.t1 = e.catch(0), e.abrupt("return", this.handleRouteInfoError(e.t1, r, a, o, s));941                                    case 30:942                                    case "end":943                                        return e.stop()944                                }945                            }), e, this, [946                                [0, 27]947                            ])948                        })));949                        return function(t, r, n, a, o, i) {950                            return e.apply(this, arguments)951                        }952                    }()953                }, {954                    key: "set",955                    value: function(e, t, r, n, a, o) {956                        return this.isFallback = !1, this.route = e, this.pathname = t, this.query = r, this.asPath = n, this.notify(a, o)957                    }958                }, {959                    key: "beforePopState",960                    value: function(e) {961                        this._bps = e962                    }963                }, {964                    key: "onlyAHashChange",965                    value: function(e) {966                        if (!this.asPath) return !1;967                        var t = this.asPath.split("#"),968                            r = s(t, 2),969                            n = r[0],970                            a = r[1],971                            o = e.split("#"),972                            i = s(o, 2),973                            u = i[0],974                            c = i[1];975                        return !(!c || n !== u || a !== c) || n === u && a !== c976                    }977                }, {978                    key: "scrollToHash",979                    value: function(e) {980                        var t = e.split("#"),981                            r = s(t, 2)[1];982                        if ("" !== r && "top" !== r) {983                            var n = document.getElementById(r);984                            if (n) n.scrollIntoView();985                            else {986                                var a = document.getElementsByName(r)[0];987                                a && a.scrollIntoView()988                            }989                        } else window.scrollTo(0, 0)990                    }991                }, {992                    key: "urlIsNew",993                    value: function(e) {994                        return this.asPath !== e995                    }996                }, {997                    key: "_resolveHref",998                    value: function(e, t) {999                        var r = !(arguments.length > 2 && void 0 !== arguments[2]) || arguments[2],1000                            n = e.pathname,1001                            a = (0, u.removePathTrailingSlash)((0, l.denormalizePagePath)(r ? S(n) : n));1002                        return "/404" === a || "/_error" === a || (t.includes(a) || t.some((function(t) {1003                            if ((0, p.isDynamicRoute)(t) && (0, g.getRouteRegex)(t).re.test(a)) return e.pathname = r ? k(t) : t, !01004                        })), e.pathname = (0, u.removePathTrailingSlash)(e.pathname)), e1005                    }1006                }, {1007                    key: "prefetch",1008                    value: function() {1009                        var e = a(n.mark((function e(t) {1010                            var r, a, o, i, s, c, l = this,1011                                f = arguments;1012                            return n.wrap((function(e) {1013                                for (;;) switch (e.prev = e.next) {1014                                    case 0:1015                                        return r = f.length > 1 && void 0 !== f[1] ? f[1] : t, a = f.length > 2 && void 0 !== f[2] ? f[2] : {}, o = (0, d.parseRelativeUrl)(t), i = o.pathname, e.next = 7, this.pageLoader.getPageList();1016                                    case 7:1017                                        s = e.sent, (o = this._resolveHref(o, s, !1)).pathname !== i && (i = o.pathname, t = (0, h.formatWithValidation)(o)), e.next = 12;1018                                        break;1019                                    case 12:1020                                        return c = (0, u.removePathTrailingSlash)(i), e.next = 15, Promise.all([this.pageLoader._isSsg(t).then((function(e) {1021                                            return !!e && l._getStaticData(l.pageLoader.getDataHref(t, r, !0, "undefined" !== typeof a.locale ? a.locale : l.locale))1022                                        })), this.pageLoader[a.priority ? "loadPage" : "prefetch"](c)]);1023                                    case 15:1024                                    case "end":1025                                        return e.stop()1026                                }1027                            }), e, this)1028                        })));1029                        return function(t) {1030                            return e.apply(this, arguments)1031                        }...

Full Screen

Full Screen

d3d28871e1b122066781901b422e4fa40a3bdd7d.4a36a385313236c59b19.dev.js

Source:d3d28871e1b122066781901b422e4fa40a3bdd7d.4a36a385313236c59b19.dev.js Github

copy

Full Screen

...507                    return e.next = 19, this.pageLoader.getPageList();508                  case 19:509                    return s = e.sent, e.next = 22, this.pageLoader.promisedBuildManifest;510                  case 22:511                    if (l = e.sent, l.__rewrites, d = (0, p.parseRelativeUrl)(n), m = (g = d).pathname, b = g.query, (d = this._resolveHref(d, s)).pathname !== m && (m = d.pathname, n = (0, h.formatWithValidation)(d)), m = m ? (0, c.removePathTrailingSlash)(P(m)) : m, this.urlIsNew(u) || (r = "replaceState"), S = (0, c.removePathTrailingSlash)(m), E = i.shallow, O = void 0 !== E && E, j = _(P(j = a), this.locale), !(0, f.isDynamicRoute)(S)) {512                      e.next = 50;513                      break;514                    }515                    if (C = (0, p.parseRelativeUrl)(j), I = C.pathname, A = (0, y.getRouteRegex)(S), T = (0, v.getRouteMatcher)(A)(I), U = (N = S === I) ? R(S, I, b) : {}, T && (!N || U.result)) {516                      e.next = 49;517                      break;518                    }519                    if (!((D = Object.keys(A.groups).filter(function (t) {520                      return !b[t];521                    })).length > 0)) {522                      e.next = 47;523                      break;524                    }525                    throw new Error((N ? "The provided `href` (".concat(n, ") value is missing query values (").concat(D.join(", "), ") to be interpolated properly. ") : "The provided `as` value (".concat(I, ") is incompatible with the `href` value (").concat(S, "). ")) + "Read more: https://err.sh/vercel/next.js/".concat(N ? "href-interpolation-failed" : "incompatible-href-as"));526                  case 47:527                    e.next = 50;528                    break;529                  case 49:530                    N ? a = (0, h.formatWithValidation)(Object.assign({}, C, {531                      pathname: U.result,532                      query: L(b, U.params)533                    })) : Object.assign(b, T);534                  case 50:535                    return t.events.emit("routeChangeStart", a), e.prev = 51, e.next = 54, this.getRouteInfo(S, m, b, a, O);536                  case 54:537                    if (W = e.sent, M = W.error, q = W.props, G = W.__N_SSG, F = W.__N_SSP, !((G || F) && q && q.pageProps && q.pageProps.__N_REDIRECT)) {538                      e.next = 65;539                      break;540                    }541                    if (!(B = q.pageProps.__N_REDIRECT).startsWith("/")) {542                      e.next = 63;543                      break;544                    }545                    if (V = (0, p.parseRelativeUrl)(B), this._resolveHref(V, s), !s.includes(V.pathname)) {546                      e.next = 63;547                      break;548                    }549                    return e.abrupt("return", this.change("replaceState", B, B, i));550                  case 63:551                    return window.location.href = B, e.abrupt("return", new Promise(function () {}));552                  case 65:553                    return t.events.emit("beforeHistoryChange", a), this.changeState(r, n, w(a, this.locale, this.defaultLocale), i), e.next = 70, this.set(S, m, b, u, W)["catch"](function (t) {554                      if (!t.cancelled) throw t;555                      M = M || t;556                    });557                  case 70:558                    if (!M) {559                      e.next = 73;560                      break;561                    }562                    throw t.events.emit("routeChangeError", M, u), M;563                  case 73:564                    return t.events.emit("routeChangeComplete", a), e.abrupt("return", !0);565                  case 78:566                    if (e.prev = 78, e.t0 = e["catch"](51), !e.t0.cancelled) {567                      e.next = 82;568                      break;569                    }570                    return e.abrupt("return", !1);571                  case 82:572                    throw e.t0;573                  case 83:574                  case "end":575                    return e.stop();576                }577              }578            }, e, this, [[51, 78]]);579          }));580          return function (t, r, n, o) {581            return e.apply(this, arguments);582          };583        }()584      }, {585        key: "changeState",586        value: function value(t, e, r) {587          var n = arguments.length > 3 && void 0 !== arguments[3] ? arguments[3] : {};588          "pushState" === t && (0, h.getURL)() === r || (this._shallow = n.shallow, window.history[t]({589            url: e,590            as: r,591            options: n,592            __N: !0593          }, "", r));594        }595      }, {596        key: "handleRouteInfoError",597        value: function () {598          var e = a(o.mark(function e(r, n, a, i, u) {599            var c, s, l, h;600            return o.wrap(function (e) {601              for (;;) {602                switch (e.prev = e.next) {603                  case 0:604                    if (!r.cancelled) {605                      e.next = 2;606                      break;607                    }608                    throw r;609                  case 2:610                    if (!(O in r) && !u) {611                      e.next = 6;612                      break;613                    }614                    throw t.events.emit("routeChangeError", r, i), window.location.href = i, b();615                  case 6:616                    return e.prev = 6, e.next = 9, this.fetchComponent("/_error");617                  case 9:618                    return c = e.sent, s = c.page, l = c.styleSheets, h = {619                      Component: s,620                      styleSheets: l,621                      err: r,622                      error: r623                    }, e.prev = 13, e.next = 16, this.getInitialProps(s, {624                      err: r,625                      pathname: n,626                      query: a627                    });628                  case 16:629                    h.props = e.sent, e.next = 23;630                    break;631                  case 19:632                    e.prev = 19, e.t0 = e["catch"](13), console.error("Error in error page `getInitialProps`: ", e.t0), h.props = {};633                  case 23:634                    return e.abrupt("return", h);635                  case 26:636                    return e.prev = 26, e.t1 = e["catch"](6), e.abrupt("return", this.handleRouteInfoError(e.t1, n, a, i, !0));637                  case 29:638                  case "end":639                    return e.stop();640                }641              }642            }, e, this, [[6, 26], [13, 19]]);643          }));644          return function (t, r, n, o, a) {645            return e.apply(this, arguments);646          };647        }()648      }, {649        key: "getRouteInfo",650        value: function () {651          var t = a(o.mark(function t(e, r, n, a) {652            var i,653                u,654                c,655                s,656                l,657                f,658                p,659                d,660                v = this,661                y = arguments;662            return o.wrap(function (t) {663              for (;;) {664                switch (t.prev = t.next) {665                  case 0:666                    if (i = y.length > 4 && void 0 !== y[4] && y[4], t.prev = 1, u = this.components[e], !i || !u || this.route !== e) {667                      t.next = 5;668                      break;669                    }670                    return t.abrupt("return", u);671                  case 5:672                    if (!u) {673                      t.next = 9;674                      break;675                    }676                    t.t0 = u, t.next = 12;677                    break;678                  case 9:679                    return t.next = 11, this.fetchComponent(e).then(function (t) {680                      return {681                        Component: t.page,682                        styleSheets: t.styleSheets,683                        __N_SSG: t.mod.__N_SSG,684                        __N_SSP: t.mod.__N_SSP685                      };686                    });687                  case 11:688                    t.t0 = t.sent;689                  case 12:690                    c = t.t0, s = c.Component, l = c.__N_SSG, f = c.__N_SSP, t.next = 18;691                    break;692                  case 18:693                    return (l || f) && (p = this.pageLoader.getDataHref((0, h.formatWithValidation)({694                      pathname: r,695                      query: n696                    }), P(a), l, this.locale, this.defaultLocale)), t.next = 21, this._getData(function () {697                      return l ? v._getStaticData(p) : f ? v._getServerData(p) : v.getInitialProps(s, {698                        pathname: r,699                        query: n,700                        asPath: a701                      });702                    });703                  case 21:704                    return d = t.sent, c.props = d, this.components[e] = c, t.abrupt("return", c);705                  case 27:706                    return t.prev = 27, t.t1 = t["catch"](1), t.abrupt("return", this.handleRouteInfoError(t.t1, r, n, a));707                  case 30:708                  case "end":709                    return t.stop();710                }711              }712            }, t, this, [[1, 27]]);713          }));714          return function (e, r, n, o) {715            return t.apply(this, arguments);716          };717        }()718      }, {719        key: "set",720        value: function value(t, e, r, n, o) {721          return this.isFallback = !1, this.route = t, this.pathname = e, this.query = r, this.asPath = n, this.notify(o);722        }723      }, {724        key: "beforePopState",725        value: function value(t) {726          this._bps = t;727        }728      }, {729        key: "onlyAHashChange",730        value: function value(t) {731          if (!this.asPath) return !1;732          var e = this.asPath.split("#"),733              r = n(e, 2),734              o = r[0],735              a = r[1],736              i = t.split("#"),737              u = n(i, 2),738              c = u[0],739              s = u[1];740          return !(!s || o !== c || a !== s) || o === c && a !== s;741        }742      }, {743        key: "scrollToHash",744        value: function value(t) {745          var e = t.split("#"),746              r = n(e, 2)[1];747          if ("" !== r) {748            var o = document.getElementById(r);749            if (o) o.scrollIntoView();else {750              var a = document.getElementsByName(r)[0];751              a && a.scrollIntoView();752            }753          } else window.scrollTo(0, 0);754        }755      }, {756        key: "urlIsNew",757        value: function value(t) {758          return this.asPath !== t;759        }760      }, {761        key: "_resolveHref",762        value: function value(t, e) {763          var r = !(arguments.length > 2 && void 0 !== arguments[2]) || arguments[2],764              n = t.pathname,765              o = (0, c.removePathTrailingSlash)((0, s.denormalizePagePath)(r ? P(n) : n));766          return "/404" === o || "/_error" === o || e.includes(o) || e.some(function (e) {767            if ((0, f.isDynamicRoute)(e) && (0, y.getRouteRegex)(e).re.test(o)) return t.pathname = r ? S(e) : e, !0;768          }), t;769        }770      }, {771        key: "prefetch",772        value: function () {773          var t = a(o.mark(function t(e) {774            var r,775                n,776                a,777                i,778                u,779                s,780                l = arguments;781            return o.wrap(function (t) {782              for (;;) {783                switch (t.prev = t.next) {784                  case 0:785                    return r = l.length > 1 && void 0 !== l[1] ? l[1] : e, n = l.length > 2 && void 0 !== l[2] ? l[2] : {}, a = (0, p.parseRelativeUrl)(e), i = a.pathname, t.next = 6, this.pageLoader.getPageList();786                  case 6:787                    u = t.sent, (a = this._resolveHref(a, u)).pathname !== i && (i = a.pathname, e = (0, h.formatWithValidation)(a)), t.next = 11;788                    break;789                  case 11:790                    return s = (0, c.removePathTrailingSlash)(i), t.next = 14, Promise.all([this.pageLoader.prefetchData(e, r, this.locale, this.defaultLocale), this.pageLoader[n.priority ? "loadPage" : "prefetch"](s)]);791                  case 14:792                  case "end":793                    return t.stop();794                }795              }796            }, t, this);797          }));798          return function (e) {799            return t.apply(this, arguments);800          };801        }()...

Full Screen

Full Screen

MaskResolver.js

Source:MaskResolver.js Github

copy

Full Screen

...21    function calculateHref(mask, cfg) {22        _validateMask(mask);23        cfg = cfg.clear ? {} : cfg;24        var url = UrlRewriter.get(Data.getRelativeUrl());25        return _resolveHref(url, mask, cfg);26    }27    exports.calculateHref = calculateHref;    // TODO Remove this?28    // TODO Remove this?29    function getAppNameByUrl(url) {30        url = UrlRewriter.get(url);31        return _getFolderNameByUrl(url) + '/Index';32    }33    exports.getAppNameByUrl = getAppNameByUrl;34    function _validateMask(mask) {35        if (mask.indexOf('/') !== -1 && mask.indexOf('=') !== -1) {36            Env_1.IoC.resolve('ILogger').error('Router.MaskResolver', 'Mask "' + mask + '" is invalid');37        }38    }39    var postfix = '/undefined/undefined/undefined/undefined/undefined/undefined/undefined/undefined/undefined/undefined';40    function _splitQueryAndHash(url) {41        var splitMatch = url.match(/[?#]/);42        if (splitMatch) {43            var index = splitMatch.index;44            return {45                path: url.substring(0, index).replace(/\/$/, ''),46                misc: url.slice(index)47            };48        }49        return {50            path: url.replace(/\/$/, ''),51            misc: ''52        };53    }54    function _calculateParams(mask, cfg, url) {55        var result = [];56        var fullMask = _generateFullMaskWithoutParams(mask, function (param) {57            result.push({58                name: param.name,59                value: cfg[param.name]60            });61        });62        var originUrl = url || Data.getRelativeUrl();63        var _a = _splitQueryAndHash(originUrl), path = _a.path, misc = _a.misc;64        originUrl = path + postfix + misc;65        var actualUrl = UrlRewriter.get(originUrl);66        var fields = actualUrl.match(fullMask);67        if (fields) {68            // fields[0] is the full url, fields[1] is prefix and fields[fields.length - 1] is suffix69            for (var j = 2; j < fields.length - 1; j++) {70                result[j - 2].urlValue = decodeURIComponent(fields[j]);    // convert 'undefined' to undefined71                // convert 'undefined' to undefined72                if (result[j - 2].urlValue === 'undefined') {73                    result[j - 2].urlValue = undefined;74                }75            }76        }77        return result;78    }79    function _generateFullMaskWithoutParams(mask, matchedParamCb) {80        var fullMask = _generateFullMask(mask);81        var paramIndexes = [];82        _matchParams(fullMask, function (param) {83            paramIndexes.push({84                prefixEnd: param.prefixEnd,85                suffixStart: param.suffixStart86            });87            matchedParamCb && matchedParamCb(param);88        });89        for (var i = paramIndexes.length - 1; i >= 0; i--) {90            fullMask = fullMask.slice(0, paramIndexes[i].prefixEnd) + '([^\\/?&#]+)' + fullMask.slice(paramIndexes[i].suffixStart);91        }92        return fullMask;93    }94    function _generateFullMask(mask) {95        var fullMask = mask;96        if (fullMask.indexOf('/') !== -1) {97            if (fullMask[0] === '/') {98                fullMask = '([/]|.*?\\.html/)' + fullMask.slice(1);99            } else {100                fullMask = '(.*?/)' + fullMask;101            }102        } else if (fullMask.indexOf('=') !== -1) {103            fullMask = '(.*?\\?|.*?&)' + fullMask;104        } else {105            fullMask = '(.*?/)' + fullMask;106        }107        if (fullMask.indexOf('=') !== -1) {108            fullMask = fullMask + '(#.*|&.+)?';109        } else {110            fullMask = fullMask + '(#.*|/.*|\\?.+)?';111        }112        return fullMask;113    }114    function _matchParams(mask, cb) {115        var re = /:(\w+)/g;116        var paramMatched = re.exec(mask);117        while (paramMatched) {118            cb({119                prefixEnd: paramMatched.index,120                suffixStart: paramMatched.index + paramMatched[0].length,121                name: paramMatched[1]122            });123            paramMatched = re.exec(mask);124        }125    }126    function _getUrlParams(params) {127        var res = {};128        params.forEach(function (param) {129            res[param.name] = param.urlValue === undefined ? undefined : decodeURIComponent(param.urlValue);130        });131        return res;132    }133    function _getCfgParams(params) {134        var res = {};135        params.forEach(function (param) {136            res[param.name] = param.value;137        });138        return res;139    }140    function _resolveHref(href, mask, cfg) {141        var params = _calculateParams(mask, cfg);142        var cfgParams = _getCfgParams(params);143        var urlParams = _getUrlParams(params);144        var toFind = _resolveMask(mask, urlParams);145        var toReplace = _resolveMask(mask, cfgParams);146        var result = href;147        if (toReplace && toReplace[0] === '/') {148            result = toReplace;149        } else if (toFind) {150            if (toReplace) {151                result = href.replace(toFind, toReplace);152            } else {153                if (href.indexOf('/' + toFind) !== -1) {154                    result = href.replace('/' + toFind, '');...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1Cypress.Commands.add('resolveHref', (href) => {2  return cy.window().then((win) => {3    return win.Cypress._resolveHref(href);4  });5});6Cypress.Commands.add('resolveHref', (href) => {7  return cy.window().then((win) => {8    return win.Cypress._resolveHref(href);9  });10});11Cypress.Commands.add('resolveHref', (href) => {12  return cy.window().then((win) => {13    return win.Cypress._resolveHref(href);14  });15});16Cypress.Commands.add('resolveHref', (href) => {17  return cy.window().then((win) => {18    return win.Cypress._resolveHref(href);19  });20});21Cypress.Commands.add('resolveHref', (href) => {22  return cy.window().then((win) => {23    return win.Cypress._resolveHref(href);24  });25});26Cypress.Commands.add('resolveHref', (href) => {27  return cy.window().then((win) => {28    return win.Cypress._resolveHref(href);29  });30});31Cypress.Commands.add('resolveHref', (href) => {32  return cy.window().then((win) => {33    return win.Cypress._resolveHref(href);34  });35});36Cypress.Commands.add('resolveHref', (href) => {37  return cy.window().then((win) => {38    return win.Cypress._resolveHref(href);39  });40});41Cypress.Commands.add('resolveHref', (href) => {42  return cy.window().then((win) => {43    return win.Cypress._resolveHref(href);44  });

Full Screen

Using AI Code Generation

copy

Full Screen

1Cypress.Commands.add('resolveHref', { prevSubject: true }, (subject, href) => {2  return win._resolveHref(href)3})4Cypress.Commands.add('resolveHref', { prevSubject: true }, (subject, href) => {5  return win._resolveHref(href)6})7Cypress.Commands.add('resolveHref', { prevSubject: true }, (subject, href) => {8  return win._resolveHref(href)9})10Cypress.Commands.add('resolveHref', { prevSubject: true }, (subject, href) => {11  return win._resolveHref(href)12})13Cypress.Commands.add('resolveHref', { prevSubject: true }, (subject, href) => {14  return win._resolveHref(href)15})16Cypress.Commands.add('resolveHref', { prevSubject: true }, (subject, href) => {17  return win._resolveHref(href)18})19Cypress.Commands.add('resolveHref', { prevSubject: true }, (subject, href) => {20  return win._resolveHref(href)21})22Cypress.Commands.add('resolveHref', { prevSubject: true }, (subject, href) => {23  return win._resolveHref(href)24})25Cypress.Commands.add('resolveHref', { prevSubject: true }, (subject, href)

Full Screen

Using AI Code Generation

copy

Full Screen

1cy.get('a').then((a) => {2  cy.log(href)3  const resolvedHref = Cypress.dom._resolveHref(href)4  cy.log(resolvedHref)5})6cy.get('a').then((a) => {7  cy.log(href)8  const resolvedHref = Cypress.dom._resolveHref(href, a[0])9  cy.log(resolvedHref)10})11cy.get('a').then((a) => {12  cy.log(href)13  const resolvedHref = Cypress.dom._resolveHref(href, a[0])14  cy.log(resolvedHref)15  cy.visit(resolvedHref)16})17cy.get('a').then((a) => {18  cy.log(href)19  const resolvedHref = Cypress.dom._resolveHref(href, a[0])20  cy.log(resolvedHref)21  cy.visit(resolvedHref)22  cy.contains('Google')23})24cy.get('a').then((a) => {25  cy.log(href)26  const resolvedHref = Cypress.dom._resolveHref(href, a[0])27  cy.log(resolvedHref)28  cy.visit(resolvedHref)29  cy.contains('Google').should('be.visible')30})

Full Screen

Using AI Code Generation

copy

Full Screen

1const _resolveHref = require('cypress/lib/util/url')._resolveHref;2const _resolveHref = require('cypress/lib/util/url')._resolveHref;3const _resolveHref = require('cypress/lib/util/url')._resolveHref;4const _resolveHref = require('cypress/lib/util/url')._resolveHref;5const _resolveHref = require('cypress/lib/util/url')._resolveHref;6const _resolveHref = require('cypress/lib/util/url')._resolveHref;7const _resolveHref = require('cypress/lib/util/url')._resolveHref;8const _resolveHref = require('cypress/lib/util/url')._resolveHref;9const _resolveHref = require('cypress/lib/util/url')._resolveHref;10const _resolveHref = require('cypress/lib/util/url')._resolveHref;

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('Test', function() {2    it('Test', function() {3        cy.get('a').then(($a) => {4            var href = $a.prop('href')5            cy.log(href)6            cy.visit(href)7        })8    })9})10Cypress.Commands.add('_resolveHref', { prevSubject: 'element' }, (el) => {11    return cy.window().then((win) => {12        const href = win.location.origin + el.prop('href')13    })14})15describe('Test', function() {16    it('Test', function() {17        cy.get('a')._resolveHref().then((href) => {18            cy.log(href)19            cy.visit(href)20        })21    })22})23describe('Test', function() {24    it('Test', function() {25        cy.get('a')._resolveHref().then((href) => {26            cy.log(href)27            cy.visit(href)28        })29    })30})31describe('Test', function() {32    it('Test', function() {33        cy.get('a')._resolveHref().then((href) => {34            cy.log(href)35            cy.visit(href)36        })37    })38})39describe('Test', function() {40    it('Test', function() {41        cy.get('a')._resolveHref().then((href) => {42            cy.log(href)43            cy.visit(href)44        })45    })46})47describe('Test', function() {48    it('Test', function() {49        cy.get('a')._resolveHref().then((href) => {50            cy.log(href)51            cy.visit(href)52        })53    })54})55describe('Test', function() {56    it('Test', function() {

Full Screen

Cypress Tutorial

Cypress is a renowned Javascript-based open-source, easy-to-use end-to-end testing framework primarily used for testing web applications. Cypress is a relatively new player in the automation testing space and has been gaining much traction lately, as evidenced by the number of Forks (2.7K) and Stars (42.1K) for the project. LambdaTest’s Cypress Tutorial covers step-by-step guides that will help you learn from the basics till you run automation tests on LambdaTest.

Chapters:

  1. What is Cypress? -
  2. Why Cypress? - Learn why Cypress might be a good choice for testing your web applications.
  3. Features of Cypress Testing - Learn about features that make Cypress a powerful and flexible tool for testing web applications.
  4. Cypress Drawbacks - Although Cypress has many strengths, it has a few limitations that you should be aware of.
  5. Cypress Architecture - Learn more about Cypress architecture and how it is designed to be run directly in the browser, i.e., it does not have any additional servers.
  6. Browsers Supported by Cypress - Cypress is built on top of the Electron browser, supporting all modern web browsers. Learn browsers that support Cypress.
  7. Selenium vs Cypress: A Detailed Comparison - Compare and explore some key differences in terms of their design and features.
  8. Cypress Learning: Best Practices - Take a deep dive into some of the best practices you should use to avoid anti-patterns in your automation tests.
  9. How To Run Cypress Tests on LambdaTest? - Set up a LambdaTest account, and now you are all set to learn how to run Cypress tests.

Certification

You can elevate your expertise with end-to-end testing using the Cypress automation framework and stay one step ahead in your career by earning a Cypress certification. Check out our Cypress 101 Certification.

YouTube

Watch this 3 hours of complete tutorial to learn the basics of Cypress and various Cypress commands with the Cypress testing at LambdaTest.

Run Cypress automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful