UNPKG

1.63 kBSource Map (JSON)View Raw
1{"version":3,"sources":["../../../next-server/server/get-route-from-entrypoint.ts"],"names":["SERVER_ROUTE_NAME_REGEX","BROWSER_ROUTE_NAME_REGEX","matchBundle","regex","input","result","exec","getRouteFromEntrypoint","entryFile","pagePath"],"mappings":"4EAAA,4G,mFAEA;AACA,KAAMA,CAAAA,uBAAuB,CAAG,kBAAhC,CACA;AACA,KAAMC,CAAAA,wBAAwB,CAAG,6BAAjC,CAEA,QAASC,CAAAA,WAAT,CAAqBC,KAArB,CAAoCC,KAApC,CAAkE,CAChE,KAAMC,CAAAA,MAAM,CAAGF,KAAK,CAACG,IAAN,CAAWF,KAAX,CAAf,CAEA,GAAI,CAACC,MAAL,CAAa,CACX,MAAO,KAAP,CACD,CAED,MAAO,mCAAuB,IAAGA,MAAM,CAAC,CAAD,CAAI,EAApC,CAAP,CACD,CAEc,QAASE,CAAAA,sBAAT,CACbC,SADa,CAEE,CACf,GAAIC,CAAAA,QAAQ,CAAGP,WAAW,CAACF,uBAAD,CAA0BQ,SAA1B,CAA1B,CAEA,GAAIC,QAAJ,CAAc,CACZ,MAAOA,CAAAA,QAAP,CACD,CAED;AACA,MAAOP,CAAAA,WAAW,CAACD,wBAAD,CAA2BO,SAA3B,CAAlB,CACD","sourcesContent":["import getRouteFromAssetPath from '../lib/router/utils/get-route-from-asset-path'\n\n// matches pages/:page*.js\nconst SERVER_ROUTE_NAME_REGEX = /^pages[/\\\\](.*)$/\n// matches static/pages/:page*.js\nconst BROWSER_ROUTE_NAME_REGEX = /^static[/\\\\]pages[/\\\\](.*)$/\n\nfunction matchBundle(regex: RegExp, input: string): string | null {\n const result = regex.exec(input)\n\n if (!result) {\n return null\n }\n\n return getRouteFromAssetPath(`/${result[1]}`)\n}\n\nexport default function getRouteFromEntrypoint(\n entryFile: string\n): string | null {\n let pagePath = matchBundle(SERVER_ROUTE_NAME_REGEX, entryFile)\n\n if (pagePath) {\n return pagePath\n }\n\n // Potentially the passed item is a browser bundle so we try to match that also\n return matchBundle(BROWSER_ROUTE_NAME_REGEX, entryFile)\n}\n"]}
\No newline at end of file