{"version":3,"file":"routes-matcher.cjs","sources":["../../node_modules/.pnpm/cookie@0.6.0/node_modules/cookie/index.js","../../src/router/routes-matcher.ts"],"sourcesContent":["/*!\n * cookie\n * Copyright(c) 2012-2014 Roman Shtylman\n * Copyright(c) 2015 Douglas Christopher Wilson\n * MIT Licensed\n */\n\n'use strict';\n\n/**\n * Module exports.\n * @public\n */\n\nexports.parse = parse;\nexports.serialize = serialize;\n\n/**\n * Module variables.\n * @private\n */\n\nvar __toString = Object.prototype.toString\n\n/**\n * RegExp to match field-content in RFC 7230 sec 3.2\n *\n * field-content = field-vchar [ 1*( SP / HTAB ) field-vchar ]\n * field-vchar   = VCHAR / obs-text\n * obs-text      = %x80-FF\n */\n\nvar fieldContentRegExp = /^[\\u0009\\u0020-\\u007e\\u0080-\\u00ff]+$/;\n\n/**\n * Parse a cookie header.\n *\n * Parse the given cookie header string into an object\n * The object has the various cookies as keys(names) => values\n *\n * @param {string} str\n * @param {object} [options]\n * @return {object}\n * @public\n */\n\nfunction parse(str, options) {\n  if (typeof str !== 'string') {\n    throw new TypeError('argument str must be a string');\n  }\n\n  var obj = {}\n  var opt = options || {};\n  var dec = opt.decode || decode;\n\n  var index = 0\n  while (index < str.length) {\n    var eqIdx = str.indexOf('=', index)\n\n    // no more cookie pairs\n    if (eqIdx === -1) {\n      break\n    }\n\n    var endIdx = str.indexOf(';', index)\n\n    if (endIdx === -1) {\n      endIdx = str.length\n    } else if (endIdx < eqIdx) {\n      // backtrack on prior semicolon\n      index = str.lastIndexOf(';', eqIdx - 1) + 1\n      continue\n    }\n\n    var key = str.slice(index, eqIdx).trim()\n\n    // only assign once\n    if (undefined === obj[key]) {\n      var val = str.slice(eqIdx + 1, endIdx).trim()\n\n      // quoted values\n      if (val.charCodeAt(0) === 0x22) {\n        val = val.slice(1, -1)\n      }\n\n      obj[key] = tryDecode(val, dec);\n    }\n\n    index = endIdx + 1\n  }\n\n  return obj;\n}\n\n/**\n * Serialize data into a cookie header.\n *\n * Serialize the a name value pair into a cookie string suitable for\n * http headers. An optional options object specified cookie parameters.\n *\n * serialize('foo', 'bar', { httpOnly: true })\n *   => \"foo=bar; httpOnly\"\n *\n * @param {string} name\n * @param {string} val\n * @param {object} [options]\n * @return {string}\n * @public\n */\n\nfunction serialize(name, val, options) {\n  var opt = options || {};\n  var enc = opt.encode || encode;\n\n  if (typeof enc !== 'function') {\n    throw new TypeError('option encode is invalid');\n  }\n\n  if (!fieldContentRegExp.test(name)) {\n    throw new TypeError('argument name is invalid');\n  }\n\n  var value = enc(val);\n\n  if (value && !fieldContentRegExp.test(value)) {\n    throw new TypeError('argument val is invalid');\n  }\n\n  var str = name + '=' + value;\n\n  if (null != opt.maxAge) {\n    var maxAge = opt.maxAge - 0;\n\n    if (isNaN(maxAge) || !isFinite(maxAge)) {\n      throw new TypeError('option maxAge is invalid')\n    }\n\n    str += '; Max-Age=' + Math.floor(maxAge);\n  }\n\n  if (opt.domain) {\n    if (!fieldContentRegExp.test(opt.domain)) {\n      throw new TypeError('option domain is invalid');\n    }\n\n    str += '; Domain=' + opt.domain;\n  }\n\n  if (opt.path) {\n    if (!fieldContentRegExp.test(opt.path)) {\n      throw new TypeError('option path is invalid');\n    }\n\n    str += '; Path=' + opt.path;\n  }\n\n  if (opt.expires) {\n    var expires = opt.expires\n\n    if (!isDate(expires) || isNaN(expires.valueOf())) {\n      throw new TypeError('option expires is invalid');\n    }\n\n    str += '; Expires=' + expires.toUTCString()\n  }\n\n  if (opt.httpOnly) {\n    str += '; HttpOnly';\n  }\n\n  if (opt.secure) {\n    str += '; Secure';\n  }\n\n  if (opt.partitioned) {\n    str += '; Partitioned'\n  }\n\n  if (opt.priority) {\n    var priority = typeof opt.priority === 'string'\n      ? opt.priority.toLowerCase()\n      : opt.priority\n\n    switch (priority) {\n      case 'low':\n        str += '; Priority=Low'\n        break\n      case 'medium':\n        str += '; Priority=Medium'\n        break\n      case 'high':\n        str += '; Priority=High'\n        break\n      default:\n        throw new TypeError('option priority is invalid')\n    }\n  }\n\n  if (opt.sameSite) {\n    var sameSite = typeof opt.sameSite === 'string'\n      ? opt.sameSite.toLowerCase() : opt.sameSite;\n\n    switch (sameSite) {\n      case true:\n        str += '; SameSite=Strict';\n        break;\n      case 'lax':\n        str += '; SameSite=Lax';\n        break;\n      case 'strict':\n        str += '; SameSite=Strict';\n        break;\n      case 'none':\n        str += '; SameSite=None';\n        break;\n      default:\n        throw new TypeError('option sameSite is invalid');\n    }\n  }\n\n  return str;\n}\n\n/**\n * URL-decode string value. Optimized to skip native call when no %.\n *\n * @param {string} str\n * @returns {string}\n */\n\nfunction decode (str) {\n  return str.indexOf('%') !== -1\n    ? decodeURIComponent(str)\n    : str\n}\n\n/**\n * URL-encode value.\n *\n * @param {string} val\n * @returns {string}\n */\n\nfunction encode (val) {\n  return encodeURIComponent(val)\n}\n\n/**\n * Determine if value is a Date.\n *\n * @param {*} val\n * @private\n */\n\nfunction isDate (val) {\n  return __toString.call(val) === '[object Date]' ||\n    val instanceof Date\n}\n\n/**\n * Try decoding a string using a decoding function.\n *\n * @param {string} str\n * @param {function} decode\n * @private\n */\n\nfunction tryDecode(str, decode) {\n  try {\n    return decode(str);\n  } catch (e) {\n    return str;\n  }\n}\n","import { parse } from 'cookie';\n\nimport { applyHeaders, applySearchParams, isUrl, parseAcceptLanguage } from '@/router/http';\nimport type { MatchPCREResult } from '@/router/pcre';\nimport { applyPCREMatches, matchPCRE } from '@/router/pcre';\nimport { checkHasField, getNextPhase, isLocaleTrailingSlashRegex } from '@/router/utils';\n\nimport type { RequestContext } from './request-context';\nimport type { Phase, RoutesGroupedByPhase, SourceRoute, WildCard } from './types';\n\nexport type ConfigMetadata = {\n\tlocales: Set<string>;\n\twildcardConfig: WildCard[] | undefined;\n};\n\nexport type RoutingMatch = {\n\tpath: string;\n\tstatus: number | undefined;\n\theaders: {\n\t\t/**\n\t\t * The headers present on a source route.\n\t\t * Gets applied to the final response before the response headers from running a function.\n\t\t */\n\t\tnormal: Headers;\n\t\t/**\n\t\t * The *important* headers - the ones present on a source route that specifies `important: true`.\n\t\t * Gets applied to the final response after the response headers from running a function.\n\t\t */\n\t\timportant: Headers;\n\t\t/**\n\t\t * Tracks if a location header is found, and what the value is, after running a middleware function.\n\t\t */\n\t\tmiddlewareLocation?: string | null;\n\t};\n\tsearchParams: URLSearchParams;\n\tbody: BodyInit | undefined | null;\n};\n\nexport type CheckRouteStatus = 'skip' | 'next' | 'done' | 'error';\nexport type CheckPhaseStatus = Extract<CheckRouteStatus, 'error' | 'done'>;\n\n/**\n * The routes matcher is used to match a request to a route and run the route's middleware.\n */\nexport class RoutesMatcher {\n\t/** URL from the request to match */\n\tprivate url: URL;\n\n\t/** Cookies from the request to match */\n\tprivate cookies: Record<string, string>;\n\n\t/** Wildcard match from the Vercel build output config */\n\tprivate wildcardMatch: WildCard | undefined;\n\n\t/** Path for the matched route */\n\tpublic path: string;\n\n\t/** Status for the response object */\n\tpublic status: number | undefined;\n\n\t/** Headers for the response object */\n\tpublic headers: RoutingMatch['headers'];\n\n\t/** Search params for the response object */\n\tpublic searchParams: URLSearchParams;\n\n\t/** Custom response body from middleware */\n\tpublic body: BodyInit | undefined | null;\n\n\t/** Counter for how many times the function to check a phase has been called */\n\tpublic checkPhaseCounter;\n\n\t/** Tracker for the middleware that have been invoked in a phase */\n\tprivate middlewareInvoked: string[];\n\n\t/** Locales found during routing */\n\tpublic locales: Set<string>;\n\n\t/**\n\t * Creates a new instance of a request matcher.\n\t *\n\t * The matcher is used to match a request to a route and run the route's middleware.\n\t *\n\t * @param routes The processed Vercel build output config routes.\n\t * @param output Vercel build output.\n\t * @param reqCtx Request context object; request object, assets fetcher, and execution context.\n\t * @param buildMetadata Metadata generated by the next-on-pages build process.\n\t * @param wildcardConfig Wildcard options from the Vercel build output config.\n\t * @returns The matched set of path, status, headers, and search params.\n\t */\n\tconstructor(\n\t\t/** Processed routes from the Vercel build output config. */\n\t\tprivate routes: RoutesGroupedByPhase,\n\t\tprivate ctx: RequestContext,\n\t\tmetadata: ConfigMetadata,\n\t) {\n\t\tthis.url = new URL(ctx.request.url);\n\t\tthis.cookies = parse(ctx.request.headers.get('cookie') || '');\n\n\t\tthis.path = this.url.pathname || '/';\n\t\tthis.headers = { normal: new Headers(), important: new Headers() };\n\t\tthis.searchParams = new URLSearchParams();\n\t\tapplySearchParams(this.searchParams, this.url.searchParams);\n\n\t\tthis.checkPhaseCounter = 0;\n\t\tthis.middlewareInvoked = [];\n\n\t\tthis.wildcardMatch = metadata.wildcardConfig?.find((w) => w.domain === this.url.hostname);\n\t\tthis.locales = metadata.locales;\n\t}\n\n\t/**\n\t * Checks if a Vercel source route from the build output config matches the request.\n\t *\n\t * @param route Build output config source route.\n\t * @param checkStatus Whether to check the status code of the route.\n\t * @returns The source path match result if the route matches, otherwise `undefined`.\n\t */\n\tprivate checkRouteMatch = (\n\t\troute: SourceRoute,\n\t\t{ checkStatus, checkIntercept }: { checkStatus: boolean; checkIntercept: boolean },\n\t): { routeMatch: MatchPCREResult; routeDest?: string } | undefined => {\n\t\tconst srcMatch = matchPCRE(route.src, this.path, route.caseSensitive);\n\t\tif (!srcMatch.match) return;\n\n\t\t// One of the HTTP `methods` conditions must be met - skip if not met.\n\t\tif (\n\t\t\troute.methods &&\n\t\t\t!route.methods.map((m) => m.toUpperCase()).includes(this.ctx.request.method.toUpperCase())\n\t\t) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst hasFieldProps = {\n\t\t\turl: this.url,\n\t\t\tcookies: this.cookies,\n\t\t\theaders: this.ctx.request.headers,\n\t\t\trouteDest: route.dest,\n\t\t};\n\n\t\t// All `has` conditions must be met - skip if one is not met.\n\t\tif (\n\t\t\troute.has?.find((has) => {\n\t\t\t\tconst result = checkHasField(has, hasFieldProps);\n\t\t\t\tif (result.newRouteDest) {\n\t\t\t\t\t// If the `has` condition had a named capture to update the destination, update it.\n\t\t\t\t\thasFieldProps.routeDest = result.newRouteDest;\n\t\t\t\t}\n\t\t\t\treturn !result.valid;\n\t\t\t})\n\t\t) {\n\t\t\treturn;\n\t\t}\n\n\t\t// All `missing` conditions must not be met - skip if one is met.\n\t\tif (route.missing?.find((has) => checkHasField(has, hasFieldProps).valid)) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Required status code must match (i.e. for error routes) - skip if not met.\n\t\tif (checkStatus && route.status !== this.status) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (checkIntercept && route.dest) {\n\t\t\tconst interceptRouteRegex = /\\/(\\(\\.+\\))+/;\n\t\t\tconst destIsIntercept = interceptRouteRegex.test(route.dest);\n\t\t\tconst pathIsIntercept = interceptRouteRegex.test(this.path);\n\n\t\t\t// If the new destination is an intercept route, only allow it if the current path is also\n\t\t\t// an intercept route.\n\t\t\tif (destIsIntercept && !pathIsIntercept) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\n\t\treturn { routeMatch: srcMatch, routeDest: hasFieldProps.routeDest };\n\t};\n\n\t/**\n\t * Processes the response from running a middleware function.\n\t *\n\t * Handles rewriting the URL and applying redirects, response headers, and overriden request headers.\n\t *\n\t * @param resp Middleware response object.\n\t */\n\tprivate processMiddlewareResp = (resp: Response): void => {\n\t\tconst overrideKey = 'x-middleware-override-headers';\n\t\tconst overrideHeader = resp.headers.get(overrideKey);\n\t\tif (overrideHeader) {\n\t\t\tconst overridenHeaderKeys = new Set(overrideHeader.split(',').map((h) => h.trim()));\n\n\t\t\tfor (const key of overridenHeaderKeys.keys()) {\n\t\t\t\tconst valueKey = `x-middleware-request-${key}`;\n\t\t\t\tconst value = resp.headers.get(valueKey);\n\n\t\t\t\tif (this.ctx.request.headers.get(key) !== value) {\n\t\t\t\t\tif (value) {\n\t\t\t\t\t\tthis.ctx.request.headers.set(key, value);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthis.ctx.request.headers.delete(key);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tresp.headers.delete(valueKey);\n\t\t\t}\n\n\t\t\tresp.headers.delete(overrideKey);\n\t\t}\n\n\t\tconst rewriteKey = 'x-middleware-rewrite';\n\t\tconst rewriteHeader = resp.headers.get(rewriteKey);\n\n\t\tif (rewriteHeader) {\n\t\t\tconst newUrl = new URL(rewriteHeader, this.url);\n\n\t\t\tconst rewriteIsExternal = this.url.hostname !== newUrl.hostname;\n\n\t\t\tthis.path = rewriteIsExternal ? `${newUrl}` : newUrl.pathname;\n\n\t\t\tapplySearchParams(this.searchParams, newUrl.searchParams);\n\n\t\t\tresp.headers.delete(rewriteKey);\n\t\t}\n\n\t\tconst middlewareNextKey = 'x-middleware-next';\n\t\tconst middlewareNextHeader = resp.headers.get(middlewareNextKey);\n\t\tif (middlewareNextHeader) {\n\t\t\tresp.headers.delete(middlewareNextKey);\n\t\t} else if (!rewriteHeader && !resp.headers.has('location')) {\n\t\t\t// We should set the final response body and status to the middleware's if it does not want\n\t\t\t// to continue and did not rewrite/redirect the URL.\n\t\t\tthis.body = resp.body;\n\t\t\tthis.status = resp.status;\n\t\t} else if (resp.headers.has('location') && resp.status >= 300 && resp.status < 400) {\n\t\t\tthis.status = resp.status;\n\t\t}\n\n\t\t// copy to the request object the headers that have been set by the middleware\n\t\tapplyHeaders(this.ctx.request.headers, resp.headers);\n\n\t\tapplyHeaders(this.headers.normal, resp.headers);\n\t\tthis.headers.middlewareLocation = resp.headers.get('location');\n\t};\n\n\t/**\n\t * Runs the middleware function for a route if it exists.\n\t *\n\t * @param path Path to the route's middleware function.\n\t * @returns Whether the middleware function was run successfully.\n\t */\n\tprivate runRouteMiddleware = async (path?: string): Promise<boolean> => {\n\t\t// If there is no path, return true as it did not result in an error.\n\t\tif (!path) return true;\n\n\t\tconst item = path && this.ctx.assets.get(path);\n\t\tif (!item || !item.isMiddleware) {\n\t\t\t// The middleware function could not be found. Set the status to 500 and bail out.\n\t\t\tthis.status = 500;\n\t\t\treturn false;\n\t\t}\n\n\t\tconst resp = await item.fetch({\n\t\t\tpath: this.path,\n\t\t\tsearchParams: this.searchParams,\n\t\t});\n\t\tthis.middlewareInvoked.push(path);\n\n\t\tif (resp.status === 500) {\n\t\t\t// The middleware function threw an error. Set the status and bail out.\n\t\t\tthis.status = resp.status;\n\t\t\treturn false;\n\t\t}\n\n\t\tthis.processMiddlewareResp(resp);\n\t\treturn true;\n\t};\n\n\t/**\n\t * Resets the response status and headers if the route should override them.\n\t *\n\t * @param route Build output config source route.\n\t */\n\tprivate applyRouteOverrides = (route: SourceRoute): void => {\n\t\tif (!route.override) return;\n\n\t\tthis.status = undefined;\n\t\tthis.headers.normal = new Headers();\n\t\tthis.headers.important = new Headers();\n\t};\n\n\t/**\n\t * Applies the route's headers for the response object.\n\t *\n\t * @param route Build output config source route.\n\t * @param srcMatch Matches from the PCRE matcher.\n\t * @param captureGroupKeys Named capture group keys from the PCRE matcher.\n\t */\n\tprivate applyRouteHeaders = (\n\t\troute: SourceRoute,\n\t\tsrcMatch: RegExpMatchArray,\n\t\tcaptureGroupKeys: string[],\n\t): void => {\n\t\tif (!route.headers) return;\n\n\t\tapplyHeaders(this.headers.normal, route.headers, {\n\t\t\tmatch: srcMatch,\n\t\t\tcaptureGroupKeys,\n\t\t});\n\n\t\tif (route.important) {\n\t\t\tapplyHeaders(this.headers.important, route.headers, {\n\t\t\t\tmatch: srcMatch,\n\t\t\t\tcaptureGroupKeys,\n\t\t\t});\n\t\t}\n\t};\n\n\t/**\n\t * Applies the route's status code for the response object.\n\t *\n\t * @param route Build output config source route.\n\t */\n\tprivate applyRouteStatus = (route: SourceRoute): void => {\n\t\tif (!route.status) return;\n\n\t\tthis.status = route.status;\n\t};\n\n\t/**\n\t * Applies the route's destination for the matching the path to the Vercel build output.\n\t *\n\t * Applies any wildcard matches to the destination.\n\t *\n\t * @param route Build output config source route.\n\t * @param srcMatch Matches from the PCRE matcher.\n\t * @param captureGroupKeys Named capture group keys from the PCRE matcher.\n\t * @returns The previous path for the route before applying the destination.\n\t */\n\tprivate applyRouteDest = (\n\t\troute: SourceRoute,\n\t\tsrcMatch: RegExpMatchArray,\n\t\tcaptureGroupKeys: string[],\n\t): string => {\n\t\tif (!route.dest) return this.path;\n\n\t\tconst prevPath = this.path;\n\t\tlet processedDest = route.dest;\n\n\t\t// Apply wildcard matches before PCRE matches\n\t\tif (this.wildcardMatch && /\\$wildcard/.test(processedDest)) {\n\t\t\tprocessedDest = processedDest.replace(/\\$wildcard/g, this.wildcardMatch.value);\n\t\t}\n\n\t\tthis.path = applyPCREMatches(processedDest, srcMatch, captureGroupKeys);\n\n\t\t// NOTE: Special handling for `/index` RSC routes. Sometimes the Vercel build output config\n\t\t// has a record to rewrite `^/` to `/index.rsc`, however, this will hit requests to pages\n\t\t// that aren't `/`. In this case, we should check that the previous path is `/`. This should\n\t\t// not match requests to `/__index.prefetch.rsc` as Vercel handles those requests missing in\n\t\t// later phases.\n\t\t// https://github.com/vercel/vercel/blob/31daff/packages/next/src/utils.ts#L3321\n\t\tconst isRscIndex = /\\/index\\.rsc$/i.test(this.path);\n\t\tconst isPrevAbsoluteIndex = /^\\/(?:index)?$/i.test(prevPath);\n\t\tconst isPrevPrefetchRscIndex = /^\\/__index\\.prefetch\\.rsc$/i.test(prevPath);\n\t\tif (isRscIndex && !isPrevAbsoluteIndex && !isPrevPrefetchRscIndex) {\n\t\t\tthis.path = prevPath;\n\t\t}\n\n\t\t// NOTE: Special handling for `.rsc` requests. If the Vercel CLI failed to generate an RSC version\n\t\t// of the page and the build output config has a record mapping the request to the RSC variant, we\n\t\t// should strip the `.rsc` extension from the path. We do not strip the extension if the request is\n\t\t// to a `.prefetch.rsc` file as Vercel handles those requests missing in later phases.\n\t\tconst isRsc = /\\.rsc$/i.test(this.path);\n\t\tconst isPrefetchRsc = /\\.prefetch\\.rsc$/i.test(this.path);\n\t\tconst pathExistsInOutput = this.ctx.assets.has(this.path);\n\t\tif (isRsc && !isPrefetchRsc && !pathExistsInOutput) {\n\t\t\tthis.path = this.path.replace(/\\.rsc/i, '');\n\t\t}\n\n\t\t// Merge search params for later use when serving a response.\n\t\tconst destUrl = new URL(this.path, this.url);\n\t\tapplySearchParams(this.searchParams, destUrl.searchParams);\n\n\t\t// If the new dest is not an URL, update the path with the path from the URL.\n\t\tif (!isUrl(this.path)) this.path = destUrl.pathname;\n\n\t\treturn prevPath;\n\t};\n\n\t/**\n\t * Applies the route's redirects for locales and internationalization.\n\t *\n\t * @param route Build output config source route.\n\t */\n\tprivate applyLocaleRedirects = (route: SourceRoute): void => {\n\t\tif (!route.locale?.redirect) return;\n\n\t\t// Automatic locale detection is only supposed to occur at the root. However, the build output\n\t\t// sometimes uses `/` as the regex instead of `^/$`. So, we should check if the `route.src` is\n\t\t// equal to the path if it is not a regular expression, to determine if we are at the root.\n\t\t// https://nextjs.org/docs/pages/building-your-application/routing/internationalization#automatic-locale-detection\n\t\tconst srcIsRegex = /^\\^(.)*$/.test(route.src);\n\t\tif (!srcIsRegex && route.src !== this.path) return;\n\n\t\t// If we already have a location header set, we might have found a locale redirect earlier.\n\t\tif (this.headers.normal.has('location')) return;\n\n\t\tconst {\n\t\t\tlocale: { redirect: redirects, cookie: cookieName },\n\t\t} = route;\n\n\t\tconst cookieValue = cookieName && this.cookies[cookieName];\n\t\tconst cookieLocales = parseAcceptLanguage(cookieValue ?? '');\n\n\t\tconst headerLocales = parseAcceptLanguage(\n\t\t\tthis.ctx.request.headers.get('accept-language') ?? '',\n\t\t);\n\n\t\t// Locales from the cookie take precedence over the header.\n\t\tconst locales = [...cookieLocales, ...headerLocales];\n\n\t\tconst redirectLocales = locales.map((locale) => redirects[locale]).filter(Boolean) as string[];\n\n\t\tconst redirectValue = redirectLocales[0];\n\t\tif (redirectValue) {\n\t\t\tconst needsRedirecting = !this.path.startsWith(redirectValue);\n\t\t\tif (needsRedirecting) {\n\t\t\t\tthis.headers.normal.set('location', redirectValue);\n\t\t\t\tthis.status = 307;\n\t\t\t}\n\t\t}\n\t};\n\n\t/**\n\t * Modifies the source route's `src` regex to be friendly with previously found locale's in the\n\t * `miss` phase.\n\t *\n\t * There is a source route generated for rewriting `/{locale}/*` to `/*` when no file was found\n\t * for the path. This causes issues when using an SSR function for the index page as the request\n\t * to `/{locale}` will not be caught by the regex. Therefore, the regex needs to be updated to\n\t * also match requests to solely `/{locale}` when the path has no trailing slash.\n\t *\n\t * @param route Build output config source route.\n\t * @param phase Current phase of the routing process.\n\t * @returns The route with the locale friendly regex.\n\t */\n\tprivate getLocaleFriendlyRoute = (route: SourceRoute, phase: Phase): SourceRoute => {\n\t\tif (!this.locales || phase !== 'miss') {\n\t\t\treturn route;\n\t\t}\n\n\t\tif (isLocaleTrailingSlashRegex(route.src, this.locales)) {\n\t\t\treturn {\n\t\t\t\t...route,\n\t\t\t\tsrc: route.src.replace(/\\/\\(\\.\\*\\)\\$$/, '(?:/(.*))?$'),\n\t\t\t};\n\t\t}\n\n\t\treturn route;\n\t};\n\n\t/**\n\t * Checks a route to see if it matches the current request.\n\t *\n\t * @param phase Current phase of the routing process.\n\t * @param route Build output config source route.\n\t * @returns The status from checking the route.\n\t */\n\tprivate checkRoute = async (phase: Phase, rawRoute: SourceRoute): Promise<CheckRouteStatus> => {\n\t\tconst localeFriendlyRoute = this.getLocaleFriendlyRoute(rawRoute, phase);\n\t\tconst { routeMatch, routeDest } =\n\t\t\tthis.checkRouteMatch(localeFriendlyRoute, {\n\t\t\t\tcheckStatus: phase === 'error',\n\t\t\t\t// The build output config correctly maps relevant request paths to be intercepts in the\n\t\t\t\t// `none` phase, while the `rewrite` phase can contain entries that rewrite to an intercept\n\t\t\t\t// that matches requests that are not actually intercepts, causing a 404.\n\t\t\t\tcheckIntercept: phase === 'rewrite',\n\t\t\t}) ?? {};\n\n\t\tconst route: SourceRoute = { ...localeFriendlyRoute, dest: routeDest };\n\n\t\t// If this route doesn't match, continue to the next one.\n\t\tif (!routeMatch?.match) return 'skip';\n\n\t\t// If this route is a middleware route, check if it has already been invoked.\n\t\tif (route.middlewarePath && this.middlewareInvoked.includes(route.middlewarePath)) {\n\t\t\treturn 'skip';\n\t\t}\n\n\t\tconst { match: srcMatch, captureGroupKeys } = routeMatch;\n\n\t\t// If this route overrides, replace the response headers and status.\n\t\tthis.applyRouteOverrides(route);\n\n\t\t// If this route has a locale, apply the redirects for it.\n\t\tthis.applyLocaleRedirects(route);\n\n\t\t// Call and process the middleware if this is a middleware route.\n\t\tconst success = await this.runRouteMiddleware(route.middlewarePath);\n\t\tif (!success) return 'error';\n\t\t// If the middleware set a response body or resulted in a redirect, we are done.\n\t\tif (this.body !== undefined || this.headers.middlewareLocation) {\n\t\t\treturn 'done';\n\t\t}\n\n\t\t// Update final headers with the ones from this route.\n\t\tthis.applyRouteHeaders(route, srcMatch, captureGroupKeys);\n\n\t\t// Update the status code if this route has one.\n\t\tthis.applyRouteStatus(route);\n\n\t\t// Update the path with the new destination.\n\t\tconst prevPath = this.applyRouteDest(route, srcMatch, captureGroupKeys);\n\n\t\t// If `check` is required and the path isn't a URL, check it again.\n\t\tif (route.check && !isUrl(this.path)) {\n\t\t\tif (prevPath === this.path) {\n\t\t\t\t// NOTE: If the current/rewritten path is the same as the one that entered the phase, it\n\t\t\t\t// can cause an infinite loop. Therefore, we should just set the status to `404` instead\n\t\t\t\t// when we are in the `miss` phase. Otherwise, we should continue to the next phase.\n\t\t\t\t// This happens with invalid `/_next/static/...` and `/_next/data/...` requests.\n\n\t\t\t\tif (phase !== 'miss') {\n\t\t\t\t\treturn this.checkPhase(getNextPhase(phase));\n\t\t\t\t}\n\n\t\t\t\tthis.status = 404;\n\t\t\t} else if (phase === 'miss') {\n\t\t\t\t// When in the `miss` phase, enter `filesystem` if the file is not in the build output. This\n\t\t\t\t// avoids rewrites in `none` that do the opposite of those in `miss`, and would cause infinite\n\t\t\t\t// loops (e.g. i18n). If it is in the build output, remove a potentially applied `404` status.\n\t\t\t\tif (!this.ctx.assets.has(this.path) && !this.ctx.assets.has(this.path.replace(/\\/$/, ''))) {\n\t\t\t\t\treturn this.checkPhase('filesystem');\n\t\t\t\t}\n\n\t\t\t\tif (this.status === 404) {\n\t\t\t\t\tthis.status = undefined;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// In all other instances, we need to enter the `none` phase so we can ensure that requests\n\t\t\t\t// for the `RSC` variant of pages are served correctly.\n\t\t\t\treturn this.checkPhase('none');\n\t\t\t}\n\t\t}\n\n\t\t// If we found a match and shouldn't continue finding matches, break out of the loop.\n\t\tif (!route.continue) {\n\t\t\treturn 'done';\n\t\t}\n\n\t\t// If the route is a redirect then we're actually done\n\t\tconst isRedirect = route.status && route.status >= 300 && route.status <= 399;\n\t\tif (isRedirect) {\n\t\t\treturn 'done';\n\t\t}\n\n\t\treturn 'next';\n\t};\n\n\t/**\n\t * Checks a phase from the routing process to see if any route matches the current request.\n\t *\n\t * @param phase Current phase for routing.\n\t * @returns The status from checking the phase.\n\t */\n\tprivate checkPhase = async (phase: Phase): Promise<CheckPhaseStatus> => {\n\t\tif (this.checkPhaseCounter++ >= 50) {\n\t\t\t// eslint-disable-next-line no-console\n\t\t\tconsole.error(`Routing encountered an infinite loop while checking ${this.url.pathname}`);\n\t\t\tthis.status = 500;\n\t\t\treturn 'error';\n\t\t}\n\n\t\t// Reset the middleware invoked list as this is a new phase.\n\t\tthis.middlewareInvoked = [];\n\t\tlet shouldContinue = true;\n\n\t\tfor (const route of this.routes[phase]) {\n\t\t\tconst result = await this.checkRoute(phase, route);\n\n\t\t\tif (result === 'error') {\n\t\t\t\treturn 'error';\n\t\t\t}\n\n\t\t\tif (result === 'done') {\n\t\t\t\tshouldContinue = false;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\t// In the `hit` phase or for external urls/redirects/middleware responses, return the match.\n\t\tif (phase === 'hit' || isUrl(this.path) || this.headers.normal.has('location') || !!this.body) {\n\t\t\treturn 'done';\n\t\t}\n\n\t\tif (phase === 'none') {\n\t\t\t// applications using the Pages router with i18n plus a catch-all root route\n\t\t\t// redirect all requests (including /api/ ones) to the catch-all route, the only\n\t\t\t// way to prevent this erroneous behavior is to remove the locale here if the\n\t\t\t// path without the locale exists in the vercel build output\n\t\t\tfor (const locale of this.locales) {\n\t\t\t\tconst localeRegExp = new RegExp(`/${locale}(/.*)`);\n\t\t\t\tconst match = this.path.match(localeRegExp);\n\t\t\t\tconst pathWithoutLocale = match?.[1];\n\t\t\t\tif (pathWithoutLocale && this.ctx.assets.has(pathWithoutLocale)) {\n\t\t\t\t\tthis.path = pathWithoutLocale;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tlet pathExistsInOutput = this.ctx.assets.has(this.path);\n\n\t\t// paths could incorrectly not be detected as existing in the output due to the `trailingSlash` setting\n\t\t// in `next.config.mjs`, so let's check for that here and update the path in such case\n\t\tif (!pathExistsInOutput && this.path.endsWith('/')) {\n\t\t\tconst newPath = this.path.replace(/\\/$/, '');\n\t\t\tpathExistsInOutput = this.ctx.assets.has(newPath);\n\t\t\tif (pathExistsInOutput) {\n\t\t\t\tthis.path = newPath;\n\t\t\t}\n\t\t}\n\n\t\t// In the `miss` phase, set status to 404 if no path was found and it isn't an error code.\n\t\tif (phase === 'miss' && !pathExistsInOutput) {\n\t\t\tconst should404 = !this.status || this.status < 400;\n\t\t\tthis.status = should404 ? 404 : this.status;\n\t\t}\n\n\t\tlet nextPhase: Phase = 'miss';\n\t\tif (pathExistsInOutput || phase === 'miss' || phase === 'error') {\n\t\t\t// If the route exists, enter the `hit` phase. For `miss` and `error` phases, enter the `hit`\n\t\t\t// phase to update headers (e.g. `x-matched-path`).\n\t\t\tnextPhase = 'hit';\n\t\t} else if (shouldContinue) {\n\t\t\tnextPhase = getNextPhase(phase);\n\t\t}\n\n\t\treturn this.checkPhase(nextPhase);\n\t};\n\n\t/**\n\t * Runs the matcher for a phase.\n\t *\n\t * @param phase The phase to start matching routes from.\n\t * @returns The status from checking for matches.\n\t */\n\tpublic run = async (\n\t\tphase: Extract<Phase, 'none' | 'error'> = 'none',\n\t): Promise<CheckPhaseStatus> => {\n\t\t// Reset the counter for each run.\n\t\tthis.checkPhaseCounter = 0;\n\t\tconst result = await this.checkPhase(phase);\n\n\t\t// Update status to redirect user to external URL.\n\t\tif (\n\t\t\tthis.headers.normal.has('location') &&\n\t\t\t(!this.status || this.status < 300 || this.status >= 400)\n\t\t) {\n\t\t\tthis.status = 307;\n\t\t}\n\n\t\treturn result;\n\t};\n}\n"],"names":["parse_1","parse","str","options","obj","opt","dec","decode","index","eqIdx","endIdx","key","val","tryDecode","RoutesMatcher","routes","ctx","metadata","route","checkStatus","checkIntercept","srcMatch","matchPCRE","m","hasFieldProps","_a","has","result","checkHasField","_b","interceptRouteRegex","destIsIntercept","pathIsIntercept","resp","overrideKey","overrideHeader","overridenHeaderKeys","h","valueKey","value","rewriteKey","rewriteHeader","newUrl","rewriteIsExternal","applySearchParams","middlewareNextKey","applyHeaders","path","item","captureGroupKeys","prevPath","processedDest","applyPCREMatches","isRscIndex","isPrevAbsoluteIndex","isPrevPrefetchRscIndex","isRsc","isPrefetchRsc","pathExistsInOutput","destUrl","isUrl","redirects","cookieName","cookieValue","cookieLocales","parseAcceptLanguage","headerLocales","redirectValue","locale","phase","isLocaleTrailingSlashRegex","rawRoute","localeFriendlyRoute","routeMatch","routeDest","getNextPhase","shouldContinue","localeRegExp","match","pathWithoutLocale","newPath","should404","nextPhase","w"],"mappings":";;;;;GAcA,IAAaA,EAAGC,EAgChB,SAASA,EAAMC,EAAKC,EAAS,CAC3B,GAAI,OAAOD,GAAQ,SACjB,MAAM,IAAI,UAAU,+BAA+B,EAQrD,QALIE,EAAM,CAAE,EACRC,EAAMF,GAAW,GACjBG,EAAMD,EAAI,QAAUE,EAEpBC,EAAQ,EACLA,EAAQN,EAAI,QAAQ,CACzB,IAAIO,EAAQP,EAAI,QAAQ,IAAKM,CAAK,EAGlC,GAAIC,IAAU,GACZ,MAGF,IAAIC,EAASR,EAAI,QAAQ,IAAKM,CAAK,EAEnC,GAAIE,IAAW,GACbA,EAASR,EAAI,eACJQ,EAASD,EAAO,CAEzBD,EAAQN,EAAI,YAAY,IAAKO,EAAQ,C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