@payloadcms/next 3.90.1 → 3.91.0-internal.07e4582

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"handleAuthRedirect.d.ts","sourceRoot":"","sources":["../../src/utilities/handleAuthRedirect.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAKxC,KAAK,IAAI,GAAG;IACV,MAAM,MAAA;IACN,KAAK,EAAE,MAAM,CAAA;IACb,YAAY,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE,CAAA;KAAE,CAAA;IAClD,IAAI,CAAC,EAAE,SAAS,CAAA;CACjB,CAAA;AAED,eAAO,MAAM,kBAAkB,0CAA2C,IAAI,KAAG,MAkChF,CAAA"}
1
+ {"version":3,"file":"handleAuthRedirect.d.ts","sourceRoot":"","sources":["../../src/utilities/handleAuthRedirect.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAKxC,KAAK,IAAI,GAAG;IACV,MAAM,MAAA;IACN,KAAK,EAAE,MAAM,CAAA;IACb,YAAY,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE,CAAA;KAAE,CAAA;IAClD,IAAI,CAAC,EAAE,SAAS,CAAA;CACjB,CAAA;AAED,eAAO,MAAM,kBAAkB,0CAA2C,IAAI,KAAG,MAuChF,CAAA"}
@@ -20,7 +20,10 @@ export const handleAuthRedirect = ({
20
20
  if (searchParams && 'redirect' in searchParams) {
21
21
  delete searchParams.redirect;
22
22
  }
23
- const redirectRoute = (route !== adminRoute ? route : '') + (Object.keys(searchParams ?? {}).length > 0 ? `${qs.stringify(searchParams, {
23
+ const redirectRoute = (route !== adminRoute ? formatAdminURL({
24
+ adminRoute: '/',
25
+ path: route
26
+ }) : '') + (Object.keys(searchParams ?? {}).length > 0 ? `${qs.stringify(searchParams, {
24
27
  addQueryPrefix: true
25
28
  })}` : '');
26
29
  const redirectTo = formatAdminURL({
@@ -1 +1 @@
1
- {"version":3,"file":"handleAuthRedirect.js","names":["formatAdminURL","qs","handleAuthRedirect","config","route","searchParams","user","admin","routes","login","loginRouteFromConfig","unauthorized","unauthorizedRoute","adminRoute","redirect","redirectRoute","Object","keys","length","stringify","addQueryPrefix","redirectTo","path","parsedLoginRouteSearchParams","parse","split","searchParamsWithRedirect"],"sources":["../../src/utilities/handleAuthRedirect.ts"],"sourcesContent":["import type { TypedUser } from 'payload'\n\nimport { formatAdminURL } from 'payload/shared'\nimport * as qs from 'qs-esm'\n\ntype Args = {\n config\n route: string\n searchParams: { [key: string]: string | string[] }\n user?: TypedUser\n}\n\nexport const handleAuthRedirect = ({ config, route, searchParams, user }: Args): string => {\n const {\n admin: {\n routes: { login: loginRouteFromConfig, unauthorized: unauthorizedRoute },\n },\n routes: { admin: adminRoute },\n } = config\n\n if (searchParams && 'redirect' in searchParams) {\n delete searchParams.redirect\n }\n\n const redirectRoute =\n (route !== adminRoute ? route : '') +\n (Object.keys(searchParams ?? {}).length > 0\n ? `${qs.stringify(searchParams, { addQueryPrefix: true })}`\n : '')\n\n const redirectTo = formatAdminURL({\n adminRoute,\n path: user ? unauthorizedRoute : loginRouteFromConfig,\n })\n\n const parsedLoginRouteSearchParams = qs.parse(redirectTo.split('?')[1] ?? '')\n\n const searchParamsWithRedirect = `${qs.stringify(\n {\n ...parsedLoginRouteSearchParams,\n ...(redirectRoute ? { redirect: redirectRoute } : {}),\n },\n { addQueryPrefix: true },\n )}`\n\n return `${redirectTo.split('?', 1)[0]}${searchParamsWithRedirect}`\n}\n"],"mappings":"AAEA,SAASA,cAAc,QAAQ;AAC/B,YAAYC,EAAA,MAAQ;AASpB,OAAO,MAAMC,kBAAA,GAAqBA,CAAC;EAAEC,MAAM;EAAEC,KAAK;EAAEC,YAAY;EAAEC;AAAI,CAAQ;EAC5E,MAAM;IACJC,KAAA,EAAO;MACLC,MAAA,EAAQ;QAAEC,KAAA,EAAOC,oBAAoB;QAAEC,YAAA,EAAcC;MAAiB;IAAE,CACzE;IACDJ,MAAA,EAAQ;MAAED,KAAA,EAAOM;IAAU;EAAE,CAC9B,GAAGV,MAAA;EAEJ,IAAIE,YAAA,IAAgB,cAAcA,YAAA,EAAc;IAC9C,OAAOA,YAAA,CAAaS,QAAQ;EAC9B;EAEA,MAAMC,aAAA,GACJ,CAACX,KAAA,KAAUS,UAAA,GAAaT,KAAA,GAAQ,EAAC,KAChCY,MAAA,CAAOC,IAAI,CAACZ,YAAA,IAAgB,CAAC,GAAGa,MAAM,GAAG,IACtC,GAAGjB,EAAA,CAAGkB,SAAS,CAACd,YAAA,EAAc;IAAEe,cAAA,EAAgB;EAAK,IAAI,GACzD,EAAC;EAEP,MAAMC,UAAA,GAAarB,cAAA,CAAe;IAChCa,UAAA;IACAS,IAAA,EAAMhB,IAAA,GAAOM,iBAAA,GAAoBF;EACnC;EAEA,MAAMa,4BAAA,GAA+BtB,EAAA,CAAGuB,KAAK,CAACH,UAAA,CAAWI,KAAK,CAAC,IAAI,CAAC,EAAE,IAAI;EAE1E,MAAMC,wBAAA,GAA2B,GAAGzB,EAAA,CAAGkB,SAAS,CAC9C;IACE,GAAGI,4BAA4B;IAC/B,IAAIR,aAAA,GAAgB;MAAED,QAAA,EAAUC;IAAc,IAAI,CAAC,CAAC;EACtD,GACA;IAAEK,cAAA,EAAgB;EAAK,IACtB;EAEH,OAAO,GAAGC,UAAA,CAAWI,KAAK,CAAC,KAAK,EAAE,CAAC,EAAE,GAAGC,wBAAA,EAA0B;AACpE","ignoreList":[]}
1
+ {"version":3,"file":"handleAuthRedirect.js","names":["formatAdminURL","qs","handleAuthRedirect","config","route","searchParams","user","admin","routes","login","loginRouteFromConfig","unauthorized","unauthorizedRoute","adminRoute","redirect","redirectRoute","path","Object","keys","length","stringify","addQueryPrefix","redirectTo","parsedLoginRouteSearchParams","parse","split","searchParamsWithRedirect"],"sources":["../../src/utilities/handleAuthRedirect.ts"],"sourcesContent":["import type { TypedUser } from 'payload'\n\nimport { formatAdminURL } from 'payload/shared'\nimport * as qs from 'qs-esm'\n\ntype Args = {\n config\n route: string\n searchParams: { [key: string]: string | string[] }\n user?: TypedUser\n}\n\nexport const handleAuthRedirect = ({ config, route, searchParams, user }: Args): string => {\n const {\n admin: {\n routes: { login: loginRouteFromConfig, unauthorized: unauthorizedRoute },\n },\n routes: { admin: adminRoute },\n } = config\n\n if (searchParams && 'redirect' in searchParams) {\n delete searchParams.redirect\n }\n\n const redirectRoute =\n (route !== adminRoute\n ? formatAdminURL({\n adminRoute: '/',\n path: route as `/${string}`,\n })\n : '') +\n (Object.keys(searchParams ?? {}).length > 0\n ? `${qs.stringify(searchParams, { addQueryPrefix: true })}`\n : '')\n\n const redirectTo = formatAdminURL({\n adminRoute,\n path: user ? unauthorizedRoute : loginRouteFromConfig,\n })\n\n const parsedLoginRouteSearchParams = qs.parse(redirectTo.split('?')[1] ?? '')\n\n const searchParamsWithRedirect = `${qs.stringify(\n {\n ...parsedLoginRouteSearchParams,\n ...(redirectRoute ? { redirect: redirectRoute } : {}),\n },\n { addQueryPrefix: true },\n )}`\n\n return `${redirectTo.split('?', 1)[0]}${searchParamsWithRedirect}`\n}\n"],"mappings":"AAEA,SAASA,cAAc,QAAQ;AAC/B,YAAYC,EAAA,MAAQ;AASpB,OAAO,MAAMC,kBAAA,GAAqBA,CAAC;EAAEC,MAAM;EAAEC,KAAK;EAAEC,YAAY;EAAEC;AAAI,CAAQ;EAC5E,MAAM;IACJC,KAAA,EAAO;MACLC,MAAA,EAAQ;QAAEC,KAAA,EAAOC,oBAAoB;QAAEC,YAAA,EAAcC;MAAiB;IAAE,CACzE;IACDJ,MAAA,EAAQ;MAAED,KAAA,EAAOM;IAAU;EAAE,CAC9B,GAAGV,MAAA;EAEJ,IAAIE,YAAA,IAAgB,cAAcA,YAAA,EAAc;IAC9C,OAAOA,YAAA,CAAaS,QAAQ;EAC9B;EAEA,MAAMC,aAAA,GACJ,CAACX,KAAA,KAAUS,UAAA,GACPb,cAAA,CAAe;IACba,UAAA,EAAY;IACZG,IAAA,EAAMZ;EACR,KACA,EAAC,KACJa,MAAA,CAAOC,IAAI,CAACb,YAAA,IAAgB,CAAC,GAAGc,MAAM,GAAG,IACtC,GAAGlB,EAAA,CAAGmB,SAAS,CAACf,YAAA,EAAc;IAAEgB,cAAA,EAAgB;EAAK,IAAI,GACzD,EAAC;EAEP,MAAMC,UAAA,GAAatB,cAAA,CAAe;IAChCa,UAAA;IACAG,IAAA,EAAMV,IAAA,GAAOM,iBAAA,GAAoBF;EACnC;EAEA,MAAMa,4BAAA,GAA+BtB,EAAA,CAAGuB,KAAK,CAACF,UAAA,CAAWG,KAAK,CAAC,IAAI,CAAC,EAAE,IAAI;EAE1E,MAAMC,wBAAA,GAA2B,GAAGzB,EAAA,CAAGmB,SAAS,CAC9C;IACE,GAAGG,4BAA4B;IAC/B,IAAIR,aAAA,GAAgB;MAAED,QAAA,EAAUC;IAAc,IAAI,CAAC,CAAC;EACtD,GACA;IAAEM,cAAA,EAAgB;EAAK,IACtB;EAEH,OAAO,GAAGC,UAAA,CAAWG,KAAK,CAAC,KAAK,EAAE,CAAC,EAAE,GAAGC,wBAAA,EAA0B;AACpE","ignoreList":[]}
@@ -0,0 +1,52 @@
1
+ import { afterEach, beforeEach, describe, expect, it } from 'vitest';
2
+ import { handleAuthRedirect } from './handleAuthRedirect.js';
3
+ describe('handleAuthRedirect', () => {
4
+ const config = {
5
+ admin: {
6
+ routes: {
7
+ login: '/login',
8
+ unauthorized: '/unauthorized'
9
+ }
10
+ },
11
+ routes: {
12
+ admin: '/admin'
13
+ }
14
+ };
15
+ const originalTrailingSlash = process.env.NEXT_TRAILING_SLASH;
16
+ beforeEach(() => {
17
+ process.env.NEXT_TRAILING_SLASH = 'true';
18
+ });
19
+ afterEach(() => {
20
+ if (originalTrailingSlash === undefined) {
21
+ delete process.env.NEXT_TRAILING_SLASH;
22
+ } else {
23
+ process.env.NEXT_TRAILING_SLASH = originalTrailingSlash;
24
+ }
25
+ });
26
+ it('should use a canonical trailing-slash path in the redirect query', () => {
27
+ const result = handleAuthRedirect({
28
+ config,
29
+ route: '/admin/collections/posts',
30
+ searchParams: {}
31
+ });
32
+ expect(result).toBe('/admin/login/?redirect=%2Fadmin%2Fcollections%2Fposts%2F');
33
+ });
34
+ it('should not add a redirect query for the admin dashboard', () => {
35
+ const result = handleAuthRedirect({
36
+ config,
37
+ route: '/admin',
38
+ searchParams: {}
39
+ });
40
+ expect(result).toBe('/admin/login/');
41
+ });
42
+ it('should preserve non-trailing-slash URLs when trailing slashes are disabled', () => {
43
+ process.env.NEXT_TRAILING_SLASH = 'false';
44
+ const result = handleAuthRedirect({
45
+ config,
46
+ route: '/admin/collections/posts',
47
+ searchParams: {}
48
+ });
49
+ expect(result).toBe('/admin/login?redirect=%2Fadmin%2Fcollections%2Fposts');
50
+ });
51
+ });
52
+ //# sourceMappingURL=handleAuthRedirect.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handleAuthRedirect.spec.js","names":["afterEach","beforeEach","describe","expect","it","handleAuthRedirect","config","admin","routes","login","unauthorized","originalTrailingSlash","process","env","NEXT_TRAILING_SLASH","undefined","result","route","searchParams","toBe"],"sources":["../../src/utilities/handleAuthRedirect.spec.ts"],"sourcesContent":["import { afterEach, beforeEach, describe, expect, it } from 'vitest'\n\nimport { handleAuthRedirect } from './handleAuthRedirect.js'\n\ndescribe('handleAuthRedirect', () => {\n const config = {\n admin: {\n routes: {\n login: '/login',\n unauthorized: '/unauthorized',\n },\n },\n routes: {\n admin: '/admin',\n },\n }\n\n const originalTrailingSlash = process.env.NEXT_TRAILING_SLASH\n\n beforeEach(() => {\n process.env.NEXT_TRAILING_SLASH = 'true'\n })\n\n afterEach(() => {\n if (originalTrailingSlash === undefined) {\n delete process.env.NEXT_TRAILING_SLASH\n } else {\n process.env.NEXT_TRAILING_SLASH = originalTrailingSlash\n }\n })\n\n it('should use a canonical trailing-slash path in the redirect query', () => {\n const result = handleAuthRedirect({\n config,\n route: '/admin/collections/posts',\n searchParams: {},\n })\n\n expect(result).toBe('/admin/login/?redirect=%2Fadmin%2Fcollections%2Fposts%2F')\n })\n\n it('should not add a redirect query for the admin dashboard', () => {\n const result = handleAuthRedirect({\n config,\n route: '/admin',\n searchParams: {},\n })\n\n expect(result).toBe('/admin/login/')\n })\n\n it('should preserve non-trailing-slash URLs when trailing slashes are disabled', () => {\n process.env.NEXT_TRAILING_SLASH = 'false'\n\n const result = handleAuthRedirect({\n config,\n route: '/admin/collections/posts',\n searchParams: {},\n })\n\n expect(result).toBe('/admin/login?redirect=%2Fadmin%2Fcollections%2Fposts')\n })\n})\n"],"mappings":"AAAA,SAASA,SAAS,EAAEC,UAAU,EAAEC,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ;AAE5D,SAASC,kBAAkB,QAAQ;AAEnCH,QAAA,CAAS,sBAAsB;EAC7B,MAAMI,MAAA,GAAS;IACbC,KAAA,EAAO;MACLC,MAAA,EAAQ;QACNC,KAAA,EAAO;QACPC,YAAA,EAAc;MAChB;IACF;IACAF,MAAA,EAAQ;MACND,KAAA,EAAO;IACT;EACF;EAEA,MAAMI,qBAAA,GAAwBC,OAAA,CAAQC,GAAG,CAACC,mBAAmB;EAE7Db,UAAA,CAAW;IACTW,OAAA,CAAQC,GAAG,CAACC,mBAAmB,GAAG;EACpC;EAEAd,SAAA,CAAU;IACR,IAAIW,qBAAA,KAA0BI,SAAA,EAAW;MACvC,OAAOH,OAAA,CAAQC,GAAG,CAACC,mBAAmB;IACxC,OAAO;MACLF,OAAA,CAAQC,GAAG,CAACC,mBAAmB,GAAGH,qBAAA;IACpC;EACF;EAEAP,EAAA,CAAG,oEAAoE;IACrE,MAAMY,MAAA,GAASX,kBAAA,CAAmB;MAChCC,MAAA;MACAW,KAAA,EAAO;MACPC,YAAA,EAA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7 @@ import { RenderServerComponent } from '@payloadcms/ui/elements/RenderServerCompo
4
4
  import { getVisibleEntities } from '@payloadcms/ui/shared';
5
5
  import { getClientConfig } from '@payloadcms/ui/utilities/getClientConfig';
6
6
  import { notFound, redirect } from 'next/navigation.js';
7
- import { applyLocaleFiltering, formatAdminURL } from 'payload/shared';
7
+ import { applyLocaleFiltering, formatAdminURL, stripTrailingSlash } from 'payload/shared';
8
8
  import * as qs from 'qs-esm';
9
9
  import React from 'react';
10
10
  import { DefaultTemplate } from '../../templates/Default/index.js';
@@ -34,11 +34,17 @@ export const RootPage = async ({
34
34
  admin: adminRoute
35
35
  }
36
36
  } = config;
37
+ const adminRouteURL = formatAdminURL({
38
+ adminRoute
39
+ });
37
40
  const params = await paramsPromise;
38
- const currentRoute = formatAdminURL({
41
+ // route with possible trailing slash
42
+ const currentRouteURL = formatAdminURL({
39
43
  adminRoute,
40
44
  path: Array.isArray(params.segments) ? `/${params.segments.join('/')}` : null
41
45
  });
46
+ // route without possible trailing slash
47
+ const currentRouteToCompare = stripTrailingSlash(currentRouteURL);
42
48
  const segments = Array.isArray(params.segments) ? params.segments : [];
43
49
  const isCollectionRoute = segments[0] === 'collections';
44
50
  const isGlobalRoute = segments[0] === 'globals';
@@ -56,7 +62,7 @@ export const RootPage = async ({
56
62
  });
57
63
  // Only redirect if there's NO custom view configured for /collections
58
64
  if (!viewKey) {
59
- redirect(adminRoute);
65
+ redirect(adminRouteURL);
60
66
  }
61
67
  }
62
68
  if (segments[1]) {
@@ -76,7 +82,7 @@ export const RootPage = async ({
76
82
  });
77
83
  // Only redirect if there's NO custom view configured for /globals
78
84
  if (!viewKey) {
79
- redirect(adminRoute);
85
+ redirect(adminRouteURL);
80
86
  }
81
87
  }
82
88
  if (segments[1]) {
@@ -113,21 +119,21 @@ export const RootPage = async ({
113
119
  })
114
120
  },
115
121
  // intentionally omit `serverURL` to keep URL relative
116
- urlSuffix: `${currentRoute}${searchParams ? queryString : ''}`
122
+ urlSuffix: `${currentRouteURL}${searchParams ? queryString : ''}`
117
123
  }
118
124
  });
119
125
  if (!permissions.canAccessAdmin && !isPublicAdminRoute({
120
126
  adminRoute,
121
127
  config: payload.config,
122
- route: currentRoute
128
+ route: currentRouteToCompare
123
129
  }) && !isCustomAdminView({
124
130
  adminRoute,
125
131
  config: payload.config,
126
- route: currentRoute
132
+ route: currentRouteToCompare
127
133
  })) {
128
134
  redirect(handleAuthRedirect({
129
135
  config: payload.config,
130
- route: currentRoute,
136
+ route: currentRouteToCompare,
131
137
  searchParams,
132
138
  user: userWithReadAccess
133
139
  }));
@@ -155,7 +161,7 @@ export const RootPage = async ({
155
161
  adminRoute,
156
162
  collectionConfig,
157
163
  collectionPreferences,
158
- currentRoute,
164
+ currentRoute: currentRouteToCompare,
159
165
  globalConfig,
160
166
  payload,
161
167
  searchParams,
@@ -175,28 +181,29 @@ export const RootPage = async ({
175
181
  notFound();
176
182
  }
177
183
  if (dbHasUser) {
178
- redirect(adminRoute);
184
+ redirect(adminRouteURL);
179
185
  }
180
186
  }
181
187
  const usersCollection = config.collections.find(({
182
188
  slug
183
189
  }) => slug === userSlug);
184
190
  const disableLocalStrategy = usersCollection?.auth?.disableLocalStrategy;
185
- const createFirstUserRoute = formatAdminURL({
191
+ const rawCreateFirstUserRoute = formatAdminURL({
186
192
  adminRoute,
187
193
  path: _createFirstUserRoute
188
194
  });
189
- if (disableLocalStrategy && currentRoute === createFirstUserRoute) {
190
- redirect(adminRoute);
195
+ const createFirstUserRoute = stripTrailingSlash(rawCreateFirstUserRoute);
196
+ if (disableLocalStrategy && currentRouteToCompare === createFirstUserRoute) {
197
+ redirect(adminRouteURL);
191
198
  }
192
- if (!dbHasUser && currentRoute !== createFirstUserRoute && !disableLocalStrategy) {
193
- redirect(createFirstUserRoute);
199
+ if (!dbHasUser && currentRouteToCompare !== createFirstUserRoute && !disableLocalStrategy) {
200
+ redirect(rawCreateFirstUserRoute);
194
201
  }
195
- if (dbHasUser && currentRoute === createFirstUserRoute) {
196
- redirect(adminRoute);
202
+ if (dbHasUser && currentRouteToCompare === createFirstUserRoute) {
203
+ redirect(adminRouteURL);
197
204
  }
198
205
  if (!DefaultView?.Component && !DefaultView?.payloadComponent && !dbHasUser) {
199
- redirect(adminRoute);
206
+ redirect(adminRouteURL);
200
207
  }
201
208
  const clientConfig = getClientConfig({
202
209
  config,
@@ -211,7 +218,7 @@ export const RootPage = async ({
211
218
  });
212
219
  // Ensure locale on req is still valid after filtering locales
213
220
  if (clientConfig.localization && req.locale && !clientConfig.localization.localeCodes.includes(req.locale)) {
214
- redirect(`${currentRoute}${qs.stringify({
221
+ redirect(`${currentRouteURL}${qs.stringify({
215
222
  ...searchParams,
216
223
  locale: clientConfig.localization.localeCodes.includes(clientConfig.localization.defaultLocale) ? clientConfig.localization.defaultLocale : clientConfig.localization.localeCodes[0]
217
224
  }, {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["PageConfigProvider","RenderServerComponent","getVisibleEntities","getClientConfig","notFound","redirect","applyLocaleFiltering","formatAdminURL","qs","React","DefaultTemplate","MinimalTemplate","getPreferences","handleAuthRedirect","initReq","isCustomAdminView","isPublicAdminRoute","getCustomViewByRoute","getRouteData","RootPage","config","configPromise","importMap","params","paramsPromise","searchParams","searchParamsPromise","admin","routes","createFirstUser","_createFirstUserRoute","user","userSlug","adminRoute","currentRoute","path","Array","isArray","segments","join","isCollectionRoute","isGlobalRoute","collectionConfig","undefined","globalConfig","length","viewKey","collections","find","slug","globals","queryString","stringify","addQueryPrefix","cookies","locale","permissions","req","payload","userWithReadAccess","key","overrides","fallbackLocale","query","parse","depth","ignoreQueryPrefix","urlSuffix","canAccessAdmin","route","collectionPreferences","folders","id","then","res","value","browseByFolderSlugs","DefaultView","documentSubViewType","routeParams","templateClassName","templateType","viewActions","viewType","dbHasUser","db","findOne","collection","doc","Component","payloadComponent","usersCollection","disableLocalStrategy","auth","createFirstUserRoute","clientConfig","i18n","localization","localeCodes","includes","defaultLocale","visibleEntities","folderID","RenderedView","clientProps","collectionSlug","docID","globalSlug","Fallback","serverProps","initPageResult","languageOptions","Object","entries","supportedLanguages","reduce","acc","language","languageConfig","keys","push","label","translations","general","thisLanguage","_jsxs","_jsx","Fragment","className"],"sources":["../../../src/views/Root/index.tsx"],"sourcesContent":["import type { I18nClient } from '@payloadcms/translations'\nimport type { Metadata } from 'next'\nimport type {\n AdminViewClientProps,\n AdminViewServerPropsOnly,\n CollectionPreferences,\n ImportMap,\n SanitizedCollectionConfig,\n SanitizedConfig,\n SanitizedGlobalConfig,\n} from 'payload'\n\nimport { PageConfigProvider } from '@payloadcms/ui'\nimport { RenderServerComponent } from '@payloadcms/ui/elements/RenderServerComponent'\nimport { getVisibleEntities } from '@payloadcms/ui/shared'\nimport { getClientConfig } from '@payloadcms/ui/utilities/getClientConfig'\nimport { notFound, redirect } from 'next/navigation.js'\nimport { applyLocaleFiltering, formatAdminURL } from 'payload/shared'\nimport * as qs from 'qs-esm'\nimport React from 'react'\n\nimport { DefaultTemplate } from '../../templates/Default/index.js'\nimport { MinimalTemplate } from '../../templates/Minimal/index.js'\nimport { getPreferences } from '../../utilities/getPreferences.js'\nimport { handleAuthRedirect } from '../../utilities/handleAuthRedirect.js'\nimport { initReq } from '../../utilities/initReq.js'\nimport { isCustomAdminView } from '../../utilities/isCustomAdminView.js'\nimport { isPublicAdminRoute } from '../../utilities/isPublicAdminRoute.js'\nimport { getCustomViewByRoute } from './getCustomViewByRoute.js'\nimport { getRouteData } from './getRouteData.js'\n\nexport type GenerateViewMetadata = (args: {\n config: SanitizedConfig\n i18n: I18nClient\n isEditing?: boolean\n params?: { [key: string]: string | string[] }\n}) => Promise<Metadata>\n\nexport const RootPage = async ({\n config: configPromise,\n importMap,\n params: paramsPromise,\n searchParams: searchParamsPromise,\n}: {\n readonly config: Promise<SanitizedConfig>\n readonly importMap: ImportMap\n readonly params: Promise<{\n segments: string[]\n }>\n readonly searchParams: Promise<{\n [key: string]: string | string[]\n }>\n}) => {\n const config = await configPromise\n\n const {\n admin: {\n routes: { createFirstUser: _createFirstUserRoute },\n user: userSlug,\n },\n routes: { admin: adminRoute },\n } = config\n\n const params = await paramsPromise\n\n const currentRoute = formatAdminURL({\n adminRoute,\n path: Array.isArray(params.segments) ? `/${params.segments.join('/')}` : null,\n })\n\n const segments = Array.isArray(params.segments) ? params.segments : []\n const isCollectionRoute = segments[0] === 'collections'\n const isGlobalRoute = segments[0] === 'globals'\n let collectionConfig: SanitizedCollectionConfig = undefined\n let globalConfig: SanitizedGlobalConfig = undefined\n\n const searchParams = await searchParamsPromise\n\n // Redirect `${adminRoute}/collections` to `${adminRoute}`\n if (isCollectionRoute) {\n if (segments.length === 1) {\n const { viewKey } = getCustomViewByRoute({\n config,\n currentRoute: '/collections',\n })\n\n // Only redirect if there's NO custom view configured for /collections\n if (!viewKey) {\n redirect(adminRoute)\n }\n }\n\n if (segments[1]) {\n collectionConfig = config.collections.find(({ slug }) => slug === segments[1])\n }\n }\n\n // Redirect `${adminRoute}/globals` to `${adminRoute}`\n if (isGlobalRoute) {\n if (segments.length === 1) {\n const { viewKey } = getCustomViewByRoute({\n config,\n currentRoute: '/globals',\n })\n\n // Only redirect if there's NO custom view configured for /globals\n if (!viewKey) {\n redirect(adminRoute)\n }\n }\n\n if (segments[1]) {\n globalConfig = config.globals.find(({ slug }) => slug === segments[1])\n }\n }\n\n if ((isCollectionRoute && !collectionConfig) || (isGlobalRoute && !globalConfig)) {\n return notFound()\n }\n\n const queryString = `${qs.stringify(searchParams ?? {}, { addQueryPrefix: true })}`\n\n const {\n cookies,\n locale,\n permissions,\n req,\n req: { payload },\n user: userWithReadAccess,\n } = await initReq({\n configPromise: config,\n importMap,\n key: 'initPage',\n overrides: {\n fallbackLocale: false,\n req: {\n query: qs.parse(queryString, {\n depth: 10,\n ignoreQueryPrefix: true,\n }),\n },\n // intentionally omit `serverURL` to keep URL relative\n urlSuffix: `${currentRoute}${searchParams ? queryString : ''}`,\n },\n })\n\n if (\n !permissions.canAccessAdmin &&\n !isPublicAdminRoute({ adminRoute, config: payload.config, route: currentRoute }) &&\n !isCustomAdminView({ adminRoute, config: payload.config, route: currentRoute })\n ) {\n redirect(\n handleAuthRedirect({\n config: payload.config,\n route: currentRoute,\n searchParams,\n user: userWithReadAccess,\n }),\n )\n }\n\n let collectionPreferences: CollectionPreferences = undefined\n\n if (collectionConfig && segments.length === 2) {\n if (config.folders && collectionConfig.folders && segments[1] !== config.folders.slug) {\n await getPreferences<CollectionPreferences>(\n `collection-${collectionConfig.slug}`,\n req.payload,\n req.user.id,\n config.admin.user,\n ).then((res) => {\n if (res && res.value) {\n collectionPreferences = res.value\n }\n })\n }\n }\n\n const {\n browseByFolderSlugs,\n DefaultView,\n documentSubViewType,\n routeParams,\n templateClassName,\n templateType,\n viewActions,\n viewType,\n } = getRouteData({\n adminRoute,\n collectionConfig,\n collectionPreferences,\n currentRoute,\n globalConfig,\n payload,\n searchParams,\n segments,\n })\n\n req.routeParams = routeParams\n\n const dbHasUser =\n req.user ||\n (await req.payload.db\n .findOne({\n collection: userSlug,\n req,\n })\n ?.then((doc) => !!doc))\n\n /**\n * This function is responsible for handling the case where the view is not found.\n * The current route did not match any default views or custom route views.\n */\n if (!DefaultView?.Component && !DefaultView?.payloadComponent) {\n if (req?.user) {\n notFound()\n }\n\n if (dbHasUser) {\n redirect(adminRoute)\n }\n }\n\n const usersCollection = config.collections.find(({ slug }) => slug === userSlug)\n const disableLocalStrategy = usersCollection?.auth?.disableLocalStrategy\n\n const createFirstUserRoute = formatAdminURL({\n adminRoute,\n path: _createFirstUserRoute,\n })\n\n if (disableLocalStrategy && currentRoute === createFirstUserRoute) {\n redirect(adminRoute)\n }\n\n if (!dbHasUser && currentRoute !== createFirstUserRoute && !disableLocalStrategy) {\n redirect(createFirstUserRoute)\n }\n\n if (dbHasUser && currentRoute === createFirstUserRoute) {\n redirect(adminRoute)\n }\n\n if (!DefaultView?.Component && !DefaultView?.payloadComponent && !dbHasUser) {\n redirect(adminRoute)\n }\n\n const clientConfig = getClientConfig({\n config,\n i18n: req.i18n,\n importMap,\n user: viewType === 'createFirstUser' ? true : userWithReadAccess,\n })\n\n await applyLocaleFiltering({ clientConfig, config, req })\n\n // Ensure locale on req is still valid after filtering locales\n if (\n clientConfig.localization &&\n req.locale &&\n !clientConfig.localization.localeCodes.includes(req.locale)\n ) {\n redirect(\n `${currentRoute}${qs.stringify(\n {\n ...searchParams,\n locale: clientConfig.localization.localeCodes.includes(\n clientConfig.localization.defaultLocale,\n )\n ? clientConfig.localization.defaultLocale\n : clientConfig.localization.localeCodes[0],\n },\n { addQueryPrefix: true },\n )}`,\n )\n }\n\n const visibleEntities = getVisibleEntities({ req })\n\n const folderID = routeParams.folderID\n\n const RenderedView = RenderServerComponent({\n clientProps: {\n browseByFolderSlugs,\n clientConfig,\n collectionSlug: collectionConfig?.slug,\n docID: routeParams.id,\n documentSubViewType,\n folderID,\n globalSlug: globalConfig?.slug,\n viewType,\n } satisfies AdminViewClientProps,\n Component: DefaultView.payloadComponent,\n Fallback: DefaultView.Component,\n importMap,\n serverProps: {\n clientConfig,\n collectionConfig,\n docID: routeParams.id,\n folderID,\n globalConfig,\n i18n: req.i18n,\n importMap,\n initPageResult: {\n collectionConfig,\n cookies,\n docID: routeParams.id,\n globalConfig,\n languageOptions: Object.entries(req.payload.config.i18n.supportedLanguages || {}).reduce(\n (acc, [language, languageConfig]) => {\n if (Object.keys(req.payload.config.i18n.supportedLanguages).includes(language)) {\n acc.push({\n label: languageConfig.translations.general.thisLanguage,\n value: language,\n })\n }\n\n return acc\n },\n [],\n ),\n locale,\n permissions,\n req,\n translations: req.i18n.translations,\n visibleEntities,\n },\n params,\n payload: req.payload,\n searchParams,\n user: userWithReadAccess,\n viewActions,\n } satisfies AdminViewServerPropsOnly,\n })\n\n return (\n <PageConfigProvider config={clientConfig}>\n {!templateType && <React.Fragment>{RenderedView}</React.Fragment>}\n {templateType === 'minimal' && (\n <MinimalTemplate className={templateClassName}>{RenderedView}</MinimalTemplate>\n )}\n {templateType === 'default' && (\n <DefaultTemplate\n collectionSlug={collectionConfig?.slug}\n docID={routeParams.id}\n documentSubViewType={documentSubViewType}\n globalSlug={globalConfig?.slug}\n i18n={req.i18n}\n locale={locale}\n params={params}\n payload={req.payload}\n permissions={permissions}\n req={req}\n searchParams={searchParams}\n user={userWithReadAccess}\n viewActions={viewActions}\n viewType={viewType}\n visibleEntities={{\n // The reason we are not passing in initPageResult.visibleEntities directly is due to a \"Cannot assign to read only property of object '#<Object>\" error introduced in React 19\n // which this caused as soon as initPageResult.visibleEntities is passed in\n collections: visibleEntities?.collections,\n globals: visibleEntities?.globals,\n }}\n >\n {RenderedView}\n </DefaultTemplate>\n )}\n </PageConfigProvider>\n )\n}\n"],"mappings":";AAYA,SAASA,kBAAkB,QAAQ;AACnC,SAASC,qBAAqB,QAAQ;AACtC,SAASC,kBAAkB,QAAQ;AACnC,SAASC,eAAe,QAAQ;AAChC,SAASC,QAAQ,EAAEC,QAAQ,QAAQ;AACnC,SAASC,oBAAoB,EAAEC,cAAc,QAAQ;AACrD,YAAYC,EAAA,MAAQ;AACpB,OAAOC,KAAA,MAAW;AAElB,SAASC,eAAe,QAAQ;AAChC,SAASC,eAAe,QAAQ;AAChC,SAASC,cAAc,QAAQ;AAC/B,SAASC,kBAAkB,QAAQ;AACnC,SAASC,OAAO,QAAQ;AACxB,SAASC,iBAAiB,QAAQ;AAClC,SAASC,kBAAkB,QAAQ;AACnC,SAASC,oBAAoB,QAAQ;AACrC,SAASC,YAAY,QAAQ;AAS7B,OAAO,MAAMC,QAAA,GAAW,MAAAA,CAAO;EAC7BC,MAAA,EAAQC,aAAa;EACrBC,SAAS;EACTC,MAAA,EAAQC,aAAa;EACrBC,YAAA,EAAcC;AAAmB,CAUlC;EACC,MAAMN,MAAA,GAAS,MAAMC,aAAA;EAErB,MAAM;IACJM,KAAA,EAAO;MACLC,MAAA,EAAQ;QAAEC,eAAA,EAAiBC;MAAqB,CAAE;MAClDC,IAAA,EAAMC;IA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B,kBAAA;MACNuB,WAAA,EAAaA,WAAA;MACbC,QAAA,EAAUA,QAAA;MACVkB,eAAA,EAAiB;QACf;QACA;QACAtD,WAAA,EAAasD,eAAA,EAAiBtD,WAAA;QAC9BG,OAAA,EAASmD,eAAA,EAAiBnD;MAC5B;gBAECqD;;;AAKX","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["PageConfigProvider","RenderServerComponent","getVisibleEntities","getClientConfig","notFound","redirect","applyLocaleFiltering","formatAdminURL","stripTrailingSlash","qs","React","DefaultTemplate","MinimalTemplate","getPreferences","handleAuthRedirect","initReq","isCustomAdminView","isPublicAdminRoute","getCustomViewByRoute","getRouteData","RootPage","config","configPromise","importMap","params","paramsPromise","searchParams","searchParamsPromise","admin","routes","createFirstUser","_createFirstUserRoute","user","userSlug","adminRoute","adminRouteURL","currentRouteURL","path","Array","isArray","segments","join","currentRouteToCompare","isCollectionRoute","isGlobalRoute","collectionConfig","undefined","globalConfig","length","viewKey","currentRoute","collections","find","slug","globals","queryString","stringify","addQueryPrefix","cookies","locale","permissions","req","payload","userWithReadAccess","key","overrides","fallbackLocale","query","parse","depth","ignoreQueryPrefix","urlSuffix","canAccessAdmin","route","collectionPreferences","folders","id","then","res","value","browseByFolderSlugs","DefaultView","documentSubViewType","routeParams","templateClassName","templateType","viewActions","viewType","dbHasUser","db","findOne","collection","doc","Component","payloadComponent","usersCollection","disableLocalStrategy","auth","rawCreateFirstUserRoute","createFirstUserRoute","clientConfig","i18n","localization","localeCodes","includes","defaultLocale","visibleEntities","folderID","RenderedView","clientProps","collectionSlug","docID","globalSlug","Fallback","serverProps","initPageResult","languageOptions","Object","entries","supportedLanguages","reduce","acc","language","languageConfig","keys","push","label","translations","general","thisLanguage","_jsxs","_jsx","Fragment","className"],"sources":["../../../src/views/Root/index.tsx"],"sourcesContent":["import type { I18nClient } from '@payloadcms/translations'\nimport type { Metadata } from 'next'\nimport type {\n AdminViewClientProps,\n AdminViewServerPropsOnly,\n CollectionPreferences,\n ImportMap,\n SanitizedCollectionConfig,\n SanitizedConfig,\n SanitizedGlobalConfig,\n} from 'payload'\n\nimport { PageConfigProvider } from '@payloadcms/ui'\nimport { RenderServerComponent } from '@payloadcms/ui/elements/RenderServerComponent'\nimport { getVisibleEntities } from '@payloadcms/ui/shared'\nimport { getClientConfig } from '@payloadcms/ui/utilities/getClientConfig'\nimport { notFound, redirect } from 'next/navigation.js'\nimport { applyLocaleFiltering, formatAdminURL, stripTrailingSlash } from 'payload/shared'\nimport * as qs from 'qs-esm'\nimport React from 'react'\n\nimport { DefaultTemplate } from '../../templates/Default/index.js'\nimport { MinimalTemplate } from '../../templates/Minimal/index.js'\nimport { getPreferences } from '../../utilities/getPreferences.js'\nimport { handleAuthRedirect } from '../../utilities/handleAuthRedirect.js'\nimport { initReq } from '../../utilities/initReq.js'\nimport { isCustomAdminView } from '../../utilities/isCustomAdminView.js'\nimport { isPublicAdminRoute } from '../../utilities/isPublicAdminRoute.js'\nimport { getCustomViewByRoute } from './getCustomViewByRoute.js'\nimport { getRouteData } from './getRouteData.js'\n\nexport type GenerateViewMetadata = (args: {\n config: SanitizedConfig\n i18n: I18nClient\n isEditing?: boolean\n params?: { [key: string]: string | string[] }\n}) => Promise<Metadata>\n\nexport const RootPage = async ({\n config: configPromise,\n importMap,\n params: paramsPromise,\n searchParams: searchParamsPromise,\n}: {\n readonly config: Promise<SanitizedConfig>\n readonly importMap: ImportMap\n readonly params: Promise<{\n segments: string[]\n }>\n readonly searchParams: Promise<{\n [key: string]: string | string[]\n }>\n}) => {\n const config = await configPromise\n\n const {\n admin: {\n routes: { createFirstUser: _createFirstUserRoute },\n user: userSlug,\n },\n routes: { admin: adminRoute },\n } = config\n const adminRouteURL = formatAdminURL({ adminRoute })\n\n const params = await paramsPromise\n\n // route with possible trailing slash\n const currentRouteURL = formatAdminURL({\n adminRoute,\n path: Array.isArray(params.segments) ? `/${params.segments.join('/')}` : null,\n })\n // route without possible trailing slash\n const currentRouteToCompare = stripTrailingSlash(currentRouteURL)\n\n const segments = Array.isArray(params.segments) ? params.segments : []\n const isCollectionRoute = segments[0] === 'collections'\n const isGlobalRoute = segments[0] === 'globals'\n let collectionConfig: SanitizedCollectionConfig = undefined\n let globalConfig: SanitizedGlobalConfig = undefined\n\n const searchParams = await searchParamsPromise\n\n // Redirect `${adminRoute}/collections` to `${adminRoute}`\n if (isCollectionRoute) {\n if (segments.length === 1) {\n const { viewKey } = getCustomViewByRoute({\n config,\n currentRoute: '/collections',\n })\n\n // Only redirect if there's NO custom view configured for /collections\n if (!viewKey) {\n redirect(adminRouteURL)\n }\n }\n\n if (segments[1]) {\n collectionConfig = config.collections.find(({ slug }) => slug === segments[1])\n }\n }\n\n // Redirect `${adminRoute}/globals` to `${adminRoute}`\n if (isGlobalRoute) {\n if (segments.length === 1) {\n const { viewKey } = getCustomViewByRoute({\n config,\n currentRoute: '/globals',\n })\n\n // Only redirect if there's NO custom view configured for /globals\n if (!viewKey) {\n redirect(adminRouteURL)\n }\n }\n\n if (segments[1]) {\n globalConfig = config.globals.find(({ slug }) => slug === segments[1])\n }\n }\n\n if ((isCollectionRoute && !collectionConfig) || (isGlobalRoute && !globalConfig)) {\n return notFound()\n }\n\n const queryString = `${qs.stringify(searchParams ?? {}, { addQueryPrefix: true })}`\n\n const {\n cookies,\n locale,\n permissions,\n req,\n req: { payload },\n user: userWithReadAccess,\n } = await initReq({\n configPromise: config,\n importMap,\n key: 'initPage',\n overrides: {\n fallbackLocale: false,\n req: {\n query: qs.parse(queryString, {\n depth: 10,\n ignoreQueryPrefix: true,\n }),\n },\n // intentionally omit `serverURL` to keep URL relative\n urlSuffix: `${currentRouteURL}${searchParams ? queryString : ''}`,\n },\n })\n\n if (\n !permissions.canAccessAdmin &&\n !isPublicAdminRoute({ adminRoute, config: payload.config, route: currentRouteToCompare }) &&\n !isCustomAdminView({ adminRoute, config: payload.config, route: currentRouteToCompare })\n ) {\n redirect(\n handleAuthRedirect({\n config: payload.config,\n route: currentRouteToCompare,\n searchParams,\n user: userWithReadAccess,\n }),\n )\n }\n\n let collectionPreferences: CollectionPreferences = undefined\n\n if (collectionConfig && segments.length === 2) {\n if (config.folders && collectionConfig.folders && segments[1] !== config.folders.slug) {\n await getPreferences<CollectionPreferences>(\n `collection-${collectionConfig.slug}`,\n req.payload,\n req.user.id,\n config.admin.user,\n ).then((res) => {\n if (res && res.value) {\n collectionPreferences = res.value\n }\n })\n }\n }\n\n const {\n browseByFolderSlugs,\n DefaultView,\n documentSubViewType,\n routeParams,\n templateClassName,\n templateType,\n viewActions,\n viewType,\n } = getRouteData({\n adminRoute,\n collectionConfig,\n collectionPreferences,\n currentRoute: currentRouteToCompare,\n globalConfig,\n payload,\n searchParams,\n segments,\n })\n\n req.routeParams = routeParams\n\n const dbHasUser =\n req.user ||\n (await req.payload.db\n .findOne({\n collection: userSlug,\n req,\n })\n ?.then((doc) => !!doc))\n\n /**\n * This function is responsible for handling the case where the view is not found.\n * The current route did not match any default views or custom route views.\n */\n if (!DefaultView?.Component && !DefaultView?.payloadComponent) {\n if (req?.user) {\n notFound()\n }\n\n if (dbHasUser) {\n redirect(adminRouteURL)\n }\n }\n\n const usersCollection = config.collections.find(({ slug }) => slug === userSlug)\n const disableLocalStrategy = usersCollection?.auth?.disableLocalStrategy\n\n const rawCreateFirstUserRoute = formatAdminURL({\n adminRoute,\n path: _createFirstUserRoute,\n })\n const createFirstUserRoute = stripTrailingSlash(rawCreateFirstUserRoute)\n\n if (disableLocalStrategy && currentRouteToCompare === createFirstUserRoute) {\n redirect(adminRouteURL)\n }\n\n if (!dbHasUser && currentRouteToCompare !== createFirstUserRoute && !disableLocalStrategy) {\n redirect(rawCreateFirstUserRoute)\n }\n\n if (dbHasUser && currentRouteToCompare === createFirstUserRoute) {\n redirect(adminRouteURL)\n }\n\n if (!DefaultView?.Component && !DefaultView?.payloadComponent && !dbHasUser) {\n redirect(adminRouteURL)\n }\n\n const clientConfig = getClientConfig({\n config,\n i18n: req.i18n,\n importMap,\n user: viewType === 'createFirstUser' ? true : userWithReadAccess,\n })\n\n await applyLocaleFiltering({ clientConfig, config, req })\n\n // Ensure locale on req is still valid after filtering locales\n if (\n clientConfig.localization &&\n req.locale &&\n !clientConfig.localization.localeCodes.includes(req.locale)\n ) {\n redirect(\n `${currentRouteURL}${qs.stringify(\n {\n ...searchParams,\n locale: clientConfig.localization.localeCodes.includes(\n clientConfig.localization.defaultLocale,\n )\n ? clientConfig.localization.defaultLocale\n : clientConfig.localization.localeCodes[0],\n },\n { addQueryPrefix: true },\n )}`,\n )\n }\n\n const visibleEntities = getVisibleEntities({ req })\n\n const folderID = routeParams.folderID\n\n const RenderedView = RenderServerComponent({\n clientProps: {\n browseByFolderSlugs,\n clientConfig,\n collectionSlug: collectionConfig?.slug,\n docID: routeParams.id,\n documentSubViewType,\n folderID,\n globalSlug: globalConfig?.slug,\n viewType,\n } satisfies AdminViewClientProps,\n Component: DefaultView.payloadComponent,\n Fallback: DefaultView.Component,\n importMap,\n serverProps: {\n clientConfig,\n collectionConfig,\n docID: routeParams.id,\n folderID,\n globalConfig,\n i18n: req.i18n,\n importMap,\n initPageResult: {\n collectionConfig,\n cookies,\n docID: routeParams.id,\n globalConfig,\n languageOptions: Object.entries(req.payload.config.i18n.supportedLanguages || {}).reduce(\n (acc, [language, languageConfig]) => {\n if (Object.keys(req.payload.config.i18n.supportedLanguages).includes(language)) {\n acc.push({\n label: languageConfig.translations.general.thisLanguage,\n value: language,\n })\n }\n\n return acc\n },\n [],\n ),\n locale,\n permissions,\n req,\n translations: req.i18n.translations,\n visibleEntities,\n },\n params,\n payload: req.payload,\n searchParams,\n user: userWithReadAccess,\n viewActions,\n } satisfies AdminViewServerPropsOnly,\n })\n\n return (\n <PageConfigProvider config={clientConfig}>\n {!templateType && <React.Fragment>{RenderedView}</React.Fragment>}\n {templateType === 'minimal' && (\n <MinimalTemplate className={templateClassName}>{RenderedView}</MinimalTemplate>\n )}\n {templateType === 'default' && (\n <DefaultTemplate\n collectionSlug={collectionConfig?.slug}\n docID={routeParams.id}\n documentSubViewType={documentSubViewType}\n globalSlug={globalConfig?.slug}\n i18n={req.i18n}\n locale={locale}\n params={params}\n payload={req.payload}\n permissions={permissions}\n req={req}\n searchParams={searchParams}\n user={userWithReadAccess}\n viewActions={viewActions}\n viewType={viewType}\n visibleEntities={{\n // The reason we are not passing in initPageResult.visibleEntities directly is due to a \"Cannot assign to read only property of object '#<Object>\" error introduced in React 19\n // which this caused as soon as initPageResult.visibleEntities is passed in\n collections: visibleEntities?.collections,\n globals: visibleEntities?.globals,\n }}\n >\n {RenderedView}\n </DefaultTemplate>\n )}\n </PageConfigProvider>\n )\n}\n"],"mappings":";AAYA,SAASA,kBAAkB,QAAQ;AACnC,SAASC,qBAAqB,QAAQ;AACtC,SAASC,kBAAkB,QAAQ;AACnC,SAASC,eAAe,QAAQ;AAChC,SAASC,QAAQ,EAAEC,QAAQ,QAAQ;AACnC,SAASC,oBAAoB,EAAEC,cAAc,EAAEC,kBAAkB,QAAQ;AACzE,YAAYC,EAAA,MAAQ;AACpB,OAAOC,KAAA,MAAW;AAElB,SAASC,eAAe,QAAQ;AAChC,SAASC,eAAe,QAAQ;AAChC,SAASC,cAAc,QAAQ;AAC/B,SAASC,kBAAkB,QAAQ;AACnC,SAASC,OAAO,QAAQ;AACxB,SAASC,iBAAiB,QAAQ;AAClC,SAASC,kBAAkB,QAAQ;AACnC,SAASC,oBAAoB,QAAQ;AACrC,SAASC,YAAY,QAAQ;AAS7B,OAAO,MAAMC,QAAA,GAAW,MAAAA,CAAO;EAC7BC,MAAA,EAAQC,aAAa;EACrBC,SAAS;EACTC,MAAA,EAAQC,aAAa;EACrBC,YAAA,EAAcC;AAAmB,CAUlC;EACC,MAAMN,MAAA,GAAS,MAAMC,aAAA;EAErB,MAAM;IACJM,KAAA,EAAO;MACLC,MAAA,EAAQ;QAAEC,eAAA,EAAiBC;MAAqB,CAAE;MAClDC,IAAA,EAAMC;IAAQ,CACf;IACDJ,MAAA,EAAQ;MAAED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d1C,MAAA,EAAQA,MAAA;MACRnC,MAAA,EAAQA,MAAA;MACRsC,OAAA,EAASD,GAAA,CAAIC,OAAO;MACpBF,WAAA,EAAaA,WAAA;MACbC,GAAA,EAAKA,GAAA;MACLnC,YAAA,EAAcA,YAAA;MACdM,IAAA,EAAM+B,kBAAA;MACNuB,WAAA,EAAaA,WAAA;MACbC,QAAA,EAAUA,QAAA;MACVmB,eAAA,EAAiB;QACf;QACA;QACAvD,WAAA,EAAauD,eAAA,EAAiBvD,WAAA;QAC9BG,OAAA,EAASoD,eAAA,EAAiBpD;MAC5B;gBAECsD;;;AAKX","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"isPathMatchingRoute.d.ts","sourceRoot":"","sources":["../../../src/views/Root/isPathMatchingRoute.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,mBAAmB,gEAM7B;IACD,YAAY,EAAE,MAAM,CAAA;IACpB,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,MAAM,CAAC,EAAE,OAAO,CAAA;CACjB,YA+BA,CAAA"}
1
+ {"version":3,"file":"isPathMatchingRoute.d.ts","sourceRoot":"","sources":["../../../src/views/Root/isPathMatchingRoute.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,mBAAmB,gEAM7B;IACD,YAAY,EAAE,MAAM,CAAA;IACpB,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,MAAM,CAAC,EAAE,OAAO,CAAA;CACjB,YAgCA,CAAA"}
@@ -1,4 +1,5 @@
1
1
  import { pathToRegexp } from 'path-to-regexp';
2
+ import { stripTrailingSlash } from 'payload/shared';
2
3
  export const isPathMatchingRoute = ({
3
4
  currentRoute,
4
5
  exact,
@@ -10,6 +11,7 @@ export const isPathMatchingRoute = ({
10
11
  if (!viewPath) {
11
12
  return false;
12
13
  }
14
+ const normalizedCurrentRoute = strict ? currentRoute : stripTrailingSlash(currentRoute);
13
15
  const keys = [];
14
16
  // run the view path through `pathToRegexp` to resolve any dynamic segments
15
17
  // i.e. `/admin/custom-view/:id` -> `/admin/custom-view/123`
@@ -17,16 +19,16 @@ export const isPathMatchingRoute = ({
17
19
  sensitive,
18
20
  strict
19
21
  });
20
- const match = regex.exec(currentRoute);
21
- const viewRoute = match?.[0] || viewPath;
22
+ const match = regex.exec(normalizedCurrentRoute);
23
+ const viewRoute = strict ? match?.[0] || viewPath : stripTrailingSlash(match?.[0] || viewPath);
22
24
  if (exact) {
23
- return currentRoute === viewRoute;
25
+ return normalizedCurrentRoute === viewRoute;
24
26
  }
25
27
  if (!exact) {
26
- if (!currentRoute.startsWith(viewRoute)) {
28
+ if (!normalizedCurrentRoute.startsWith(viewRoute)) {
27
29
  return false;
28
30
  }
29
- const remainingPath = currentRoute.slice(viewRoute.length);
31
+ const remainingPath = normalizedCurrentRoute.slice(viewRoute.length);
30
32
  return remainingPath === '' || remainingPath.startsWith('/');
31
33
  }
32
34
  };
@@ -1 +1 @@
1
- {"version":3,"file":"isPathMatchingRoute.js","names":["pathToRegexp","isPathMatchingRoute","currentRoute","exact","path","viewPath","sensitive","strict","keys","regex","match","exec","viewRoute","startsWith","remainingPath","slice","length"],"sources":["../../../src/views/Root/isPathMatchingRoute.ts"],"sourcesContent":["import { pathToRegexp } from 'path-to-regexp'\n\nexport const isPathMatchingRoute = ({\n currentRoute,\n exact,\n path: viewPath,\n sensitive,\n strict,\n}: {\n currentRoute: string\n exact?: boolean\n path?: string\n sensitive?: boolean\n strict?: boolean\n}) => {\n // if no path is defined, we cannot match it so return false early\n if (!viewPath) {\n return false\n }\n\n const keys = []\n\n // run the view path through `pathToRegexp` to resolve any dynamic segments\n // i.e. `/admin/custom-view/:id` -> `/admin/custom-view/123`\n const regex = pathToRegexp(viewPath, keys, {\n sensitive,\n strict,\n })\n\n const match = regex.exec(currentRoute)\n const viewRoute = match?.[0] || viewPath\n\n if (exact) {\n return currentRoute === viewRoute\n }\n\n if (!exact) {\n if (!currentRoute.startsWith(viewRoute)) {\n return false\n }\n\n const remainingPath = currentRoute.slice(viewRoute.length)\n\n return remainingPath === '' || remainingPath.startsWith('/')\n }\n}\n"],"mappings":"AAAA,SAASA,YAAY,QAAQ;AAE7B,OAAO,MAAMC,mBAAA,GAAsBA,CAAC;EAClCC,YAAY;EACZC,KAAK;EACLC,IAAA,EAAMC,QAAQ;EACdC,SAAS;EACTC;AAAM,CAOP;EACC;EACA,IAAI,CAACF,QAAA,EAAU;IACb,OAAO;EACT;EAEA,MAAMG,IAAA,GAAO,EAAE;EAEf;EACA;EACA,MAAMC,KAAA,GAAQT,YAAA,CAAaK,QAAA,EAAUG,IAAA,EAAM;IACzCF,SAAA;IACAC;EACF;EAEA,MAAMG,KAAA,GAAQD,KAAA,CAAME,IAAI,CAACT,YAAA;EACzB,MAAMU,SAAA,GAAYF,KAAA,GAAQ,EAAE,IAAIL,QAAA;EAEhC,IAAIF,KAAA,EAAO;IACT,OAAOD,YAAA,KAAiBU,SAAA;EAC1B;EAEA,IAAI,CAACT,KAAA,EAAO;IACV,IAAI,CAACD,YAAA,CAAaW,UAAU,CAACD,SAAA,GAAY;MACvC,OAAO;IACT;IAEA,MAAME,aAAA,GAAgBZ,YAAA,CAAaa,KAAK,CAACH,SAAA,CAAUI,MAAM;IAEzD,OAAOF,aAAA,KAAkB,MAAMA,aAAA,CAAcD,UAAU,CAAC;EAC1D;AACF","ignoreList":[]}
1
+ {"version":3,"file":"isPathMatchingRoute.js","names":["pathToRegexp","stripTrailingSlash","isPathMatchingRoute","currentRoute","exact","path","viewPath","sensitive","strict","normalizedCurrentRoute","keys","regex","match","exec","viewRoute","startsWith","remainingPath","slice","length"],"sources":["../../../src/views/Root/isPathMatchingRoute.ts"],"sourcesContent":["import { pathToRegexp } from 'path-to-regexp'\nimport { stripTrailingSlash } from 'payload/shared'\n\nexport const isPathMatchingRoute = ({\n currentRoute,\n exact,\n path: viewPath,\n sensitive,\n strict,\n}: {\n currentRoute: string\n exact?: boolean\n path?: string\n sensitive?: boolean\n strict?: boolean\n}) => {\n // if no path is defined, we cannot match it so return false early\n if (!viewPath) {\n return false\n }\n\n const normalizedCurrentRoute = strict ? currentRoute : stripTrailingSlash(currentRoute)\n const keys = []\n\n // run the view path through `pathToRegexp` to resolve any dynamic segments\n // i.e. `/admin/custom-view/:id` -> `/admin/custom-view/123`\n const regex = pathToRegexp(viewPath, keys, {\n sensitive,\n strict,\n })\n\n const match = regex.exec(normalizedCurrentRoute)\n const viewRoute = strict ? match?.[0] || viewPath : stripTrailingSlash(match?.[0] || viewPath)\n\n if (exact) {\n return normalizedCurrentRoute === viewRoute\n }\n\n if (!exact) {\n if (!normalizedCurrentRoute.startsWith(viewRoute)) {\n return false\n }\n\n const remainingPath = normalizedCurrentRoute.slice(viewRoute.length)\n\n return remainingPath === '' || remainingPath.startsWith('/')\n }\n}\n"],"mappings":"AAAA,SAASA,YAAY,QAAQ;AAC7B,SAASC,kBAAkB,QAAQ;AAEnC,OAAO,MAAMC,mBAAA,GAAsBA,CAAC;EAClCC,YAAY;EACZC,KAAK;EACLC,IAAA,EAAMC,QAAQ;EACdC,SAAS;EACTC;AAAM,CAOP;EACC;EACA,IAAI,CAACF,QAAA,EAAU;IACb,OAAO;EACT;EAEA,MAAMG,sBAAA,GAAyBD,MAAA,GAASL,YAAA,GAAeF,kBAAA,CAAmBE,YAAA;EAC1E,MAAMO,IAAA,GAAO,EAAE;EAEf;EACA;EACA,MAAMC,KAAA,GAAQX,YAAA,CAAaM,QAAA,EAAUI,IAAA,EAAM;IACzCH,SAAA;IACAC;EACF;EAEA,MAAMI,KAAA,GAAQD,KAAA,CAAME,IAAI,CAACJ,sBAAA;EACzB,MAAMK,SAAA,GAAYN,MAAA,GAASI,KAAA,GAAQ,EAAE,IAAIN,QAAA,GAAWL,kBAAA,CAAmBW,KAAA,GAAQ,EAAE,IAAIN,QAAA;EAErF,IAAIF,KAAA,EAAO;IACT,OAAOK,sBAAA,KAA2BK,SAAA;EACpC;EAEA,IAAI,CAACV,KAAA,EAAO;IACV,IAAI,CAACK,sBAAA,CAAuBM,UAAU,CAACD,SAAA,GAAY;MACjD,OAAO;IACT;IAEA,MAAME,aAAA,GAAgBP,sBAAA,CAAuBQ,KAAK,CAACH,SAAA,CAAUI,MAAM;IAEnE,OAAOF,aAAA,KAAkB,MAAMA,aAAA,CAAcD,UAAU,CAAC;EAC1D;AACF","ignoreList":[]}
@@ -23,6 +23,13 @@ describe('isPathMatchingRoute', () => {
23
23
  path: '/dashboard'
24
24
  })).toBe(true);
25
25
  });
26
+ it('should match a trailing-slash path with a normalized current route', () => {
27
+ expect(isPathMatchingRoute({
28
+ currentRoute: '/dashboard',
29
+ exact: true,
30
+ path: '/dashboard/'
31
+ })).toBe(true);
32
+ });
26
33
  it('should not match when currentRoute differs from the path', () => {
27
34
  expect(isPathMatchingRoute({
28
35
  currentRoute: '/settings',
@@ -1 +1 @@
1
- {"version":3,"file":"isPathMatchingRoute.spec.js","names":["describe","expect","it","isPathMatchingRoute","currentRoute","path","undefined","toBe","exact","sensitive","strict"],"sources":["../../../src/views/Root/isPathMatchingRoute.spec.ts"],"sourcesContent":["import { describe, expect, it } from 'vitest'\n\nimport { isPathMatchingRoute } from './isPathMatchingRoute.js'\n\ndescribe('isPathMatchingRoute', () => {\n describe('no path defined', () => {\n it('should return false when path is undefined', () => {\n expect(isPathMatchingRoute({ currentRoute: '/anything', path: undefined })).toBe(false)\n })\n\n it('should return false when path is empty string', () => {\n expect(isPathMatchingRoute({ currentRoute: '/anything', path: '' })).toBe(false)\n })\n })\n\n describe('exact matching', () => {\n it('should match when currentRoute exactly equals the static path', () => {\n expect(\n isPathMatchingRoute({ currentRoute: '/dashboard', exact: true, path: '/dashboard' }),\n ).toBe(true)\n })\n\n it('should not match when currentRoute differs from the path', () => {\n expect(\n isPathMatchingRoute({ currentRoute: '/settings', exact: true, path: '/dashboard' }),\n ).toBe(false)\n })\n\n it('should not match a sub-path when exact is true', () => {\n expect(\n isPathMatchingRoute({\n currentRoute: '/dashboard/settings',\n exact: true,\n path: '/dashboard',\n }),\n ).toBe(false)\n })\n\n it('should match a parameterized path exactly', () => {\n expect(\n isPathMatchingRoute({\n currentRoute: '/custom/123',\n exact: true,\n path: '/custom/:id',\n }),\n ).toBe(true)\n })\n\n it('should not match a parameterized path with extra segments', () => {\n expect(\n isPathMatchingRoute({\n currentRoute: '/custom/123/edit',\n exact: true,\n path: '/custom/:id',\n }),\n ).toBe(false)\n })\n\n it('should match root path exactly', () => {\n expect(isPathMatchingRoute({ currentRoute: '/', exact: true, path: '/' })).toBe(true)\n })\n\n it('should not match root path against other routes when exact', () => {\n expect(isPathMatchingRoute({ currentRoute: '/login', exact: true, path: '/' })).toBe(false)\n })\n })\n\n describe('non-exact (prefix) matching', () => {\n it('should match when currentRoute equals the path', () => {\n expect(isPathMatchingRoute({ currentRoute: '/dashboard', path: '/dashboard' })).toBe(true)\n })\n\n it('should match a sub-path at a segment boundary', () => {\n expect(isPathMatchingRoute({ currentRoute: '/dashboard/settings', path: '/dashboard' })).toBe(\n true,\n )\n })\n\n it('should match deeply nested sub-paths', () => {\n expect(\n isPathMatchingRoute({\n currentRoute: '/dashboard/settings/advanced/debug',\n path: '/dashboard',\n }),\n ).toBe(true)\n })\n\n it('should not match when route shares a prefix but not at a segment boundary', () => {\n expect(isPathMatchingRoute({ currentRoute: '/dashboard-extra', path: '/dashboard' })).toBe(\n false,\n )\n })\n\n it('should not match a completely different route', () => {\n expect(isPathMatchingRoute({ currentRoute: '/settings', path: '/dashboard' })).toBe(false)\n })\n\n it('should match a parameterized path with a sub-path', () => {\n expect(\n isPathMatchingRoute({\n currentRoute: '/custom/123/edit',\n path: '/custom/:id',\n }),\n ).toBe(false)\n // pathToRegexp is end-anchored by default, so /custom/:id does not match /custom/123/edit.\n // The literal fallback '/custom/:id' also won't startsWith-match.\n // Parameterized views should use exact: true or include all segments in the pattern.\n })\n\n it('should match when :id captures the full segment including non-slash characters', () => {\n expect(\n isPathMatchingRoute({\n currentRoute: '/custom/123extra',\n path: '/custom/:id',\n }),\n ).toBe(true)\n // :id captures everything up to the next / — '123extra' is a valid :id value\n })\n })\n\n describe('root path / without exact — regression for route shadowing bug', () => {\n it('should match root path against itself', () => {\n expect(isPathMatchingRoute({ currentRoute: '/', path: '/' })).toBe(true)\n })\n\n it('should not match root path against /login', () => {\n expect(isPathMatchingRoute({ currentRoute: '/login', path: '/' })).toBe(false)\n })\n\n it('should not match root path against /collections/posts', () => {\n expect(isPathMatchingRoute({ currentRoute: '/collections/posts', path: '/' })).toBe(false)\n })\n\n it('should not match root path against /collections/posts/123', () => {\n expect(isPathMatchingRoute({ currentRoute: '/collections/posts/123', path: '/' })).toBe(false)\n })\n })\n\n describe('sensitive option', () => {\n it('should match case-insensitively by default', () => {\n expect(\n isPathMatchingRoute({\n currentRoute: '/Dashboard',\n exact: true,\n path: '/dashboard',\n }),\n ).toBe(true)\n })\n\n it('should not match different cases when sensitive is true', () => {\n expect(\n isPathMatchingRoute({\n currentRoute: '/Dashboard',\n exact: true,\n path: '/dashboard',\n sensitive: true,\n }),\n ).toBe(false)\n })\n })\n\n describe('strict option', () => {\n it('should match with or without trailing slash by default', () => {\n expect(\n isPathMatchingRoute({\n currentRoute: '/dashboard/',\n exact: true,\n path: '/dashboard',\n }),\n ).toBe(true)\n })\n\n it('should not match trailing slash mismatch when strict is true', () => {\n expect(\n isPathMatchingRoute({\n currentRoute: '/dashboard/',\n exact: true,\n path: '/dashboard',\n strict: true,\n }),\n ).toBe(false)\n })\n })\n})\n"],"mappings":"AAAA,SAASA,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ;AAErC,SAASC,mBAAmB,QAAQ;AAEpCH,QAAA,CAAS,uBAAuB;EAC9BA,QAAA,CAAS,mBAAmB;IAC1BE,EAAA,CAAG,8CAA8C;MAC/CD,MAAA,CA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MAAA,CAAOE,mBAAA,CAAoB;QAAEC,YAAA,EAAc;QAAUC,IAAA,EAAM;MAAI,IAAIE,IAAI,CAAC;IAC1E;IAEAL,EAAA,CAAG,yDAAyD;MAC1DD,MAAA,CAAOE,mBAAA,CAAoB;QAAEC,YAAA,EAAc;QAAsBC,IAAA,EAAM;MAAI,IAAIE,IAAI,CAAC;IACtF;IAEAL,EAAA,CAAG,6DAA6D;MAC9DD,MAAA,CAAOE,mBAAA,CAAoB;QAAEC,YAAA,EAAc;QAA0BC,IAAA,EAAM;MAAI,IAAIE,IAAI,CAAC;IAC1F;EACF;EAEAP,QAAA,CAAS,oBAAoB;IAC3BE,EAAA,CAAG,8CAA8C;MAC/CD,MAAA,CACEE,mBAAA,CAAoB;QAClBC,YAAA,EAAc;QACdI,KAAA,EAAO;QACPH,IAAA,EAAM;MACR,IACAE,IAAI,CAAC;IACT;IAEAL,EAAA,CAAG,2DAA2D;MAC5DD,MAAA,CACEE,mBAAA,CAAoB;QAClBC,YAAA,EAAc;QACdI,KAAA,EAAO;QACPH,IAAA,EAAM;QACNI,SAAA,EAAW;MACb,IACAF,IAAI,CAAC;IACT;EACF;EAEAP,QAAA,CAAS,iBAAiB;IACxBE,EAAA,CAAG,0DAA0D;MAC3DD,MAAA,CACEE,mBAAA,CAAoB;QAClBC,YAAA,EAAc;QACdI,KAAA,EAAO;QACPH,IAAA,EAAM;MACR,IACAE,IAAI,CAAC;IACT;IAEAL,EAAA,CAAG,gEAAgE;MACjED,MAAA,CACEE,mBAAA,CAAoB;QAClBC,YAAA,EAAc;QACdI,KAAA,EAAO;QACPH,IAAA,EAAM;QACNK,MAAA,EAAQ;MACV,IACAH,IAAI,CAAC;IACT;EACF;AACF","ignoreList":[]}
1
+ {"version":3,"file":"isPathMatchingRoute.spec.js","names":["describe","expect","it","isPathMatchingRoute","currentRoute","path","undefined","toBe","exact","sensitive","strict"],"sources":["../../../src/views/Root/isPathMatchingRoute.spec.ts"],"sourcesContent":["import { describe, expect, it } from 'vitest'\n\nimport { isPathMatchingRoute } from './isPathMatchingRoute.js'\n\ndescribe('isPathMatchingRoute', () => {\n describe('no path defined', () => {\n it('should return false when path is undefined', () => {\n expect(isPathMatchingRoute({ currentRoute: '/anything', path: undefined })).toBe(false)\n })\n\n it('should return false when path is empty string', () => {\n expect(isPathMatchingRoute({ currentRoute: '/anything', path: '' })).toBe(false)\n })\n })\n\n describe('exact matching', () => {\n it('should match when currentRoute exactly equals the static path', () => {\n expect(\n isPathMatchingRoute({ currentRoute: '/dashboard', exact: true, path: '/dashboard' }),\n ).toBe(true)\n })\n\n it('should match a trailing-slash path with a normalized current route', () => {\n expect(\n isPathMatchingRoute({ currentRoute: '/dashboard', exact: true, path: '/dashboard/' }),\n ).toBe(true)\n })\n\n it('should not match when currentRoute differs from the path', () => {\n expect(\n isPathMatchingRoute({ currentRoute: '/settings', exact: true, path: '/dashboard' }),\n ).toBe(false)\n })\n\n it('should not match a sub-path when exact is true', () => {\n expect(\n isPathMatchingRoute({\n currentRoute: '/dashboard/settings',\n exact: true,\n path: '/dashboard',\n }),\n ).toBe(false)\n })\n\n it('should match a parameterized path exactly', () => {\n expect(\n isPathMatchingRoute({\n currentRoute: '/custom/123',\n exact: true,\n path: '/custom/:id',\n }),\n ).toBe(true)\n })\n\n it('should not match a parameterized path with extra segments', () => {\n expect(\n isPathMatchingRoute({\n currentRoute: '/custom/123/edit',\n exact: true,\n path: '/custom/:id',\n }),\n ).toBe(false)\n })\n\n it('should match root path exactly', () => {\n expect(isPathMatchingRoute({ currentRoute: '/', exact: true, path: '/' })).toBe(true)\n })\n\n it('should not match root path against other routes when exact', () => {\n expect(isPathMatchingRoute({ currentRoute: '/login', exact: true, path: '/' })).toBe(false)\n })\n })\n\n describe('non-exact (prefix) matching', () => {\n it('should match when currentRoute equals the path', () => {\n expect(isPathMatchingRoute({ currentRoute: '/dashboard', path: '/dashboard' })).toBe(true)\n })\n\n it('should match a sub-path at a segment boundary', () => {\n expect(isPathMatchingRoute({ currentRoute: '/dashboard/settings', path: '/dashboard' })).toBe(\n true,\n )\n })\n\n it('should match deeply nested sub-paths', () => {\n expect(\n isPathMatchingRoute({\n currentRoute: '/dashboard/settings/advanced/debug',\n path: '/dashboard',\n }),\n ).toBe(true)\n })\n\n it('should not match when route shares a prefix but not at a segment boundary', () => {\n expect(isPathMatchingRoute({ currentRoute: '/dashboard-extra', path: '/dashboard' })).toBe(\n false,\n )\n })\n\n it('should not match a completely different route', () => {\n expect(isPathMatchingRoute({ currentRoute: '/settings', path: '/dashboard' })).toBe(false)\n })\n\n it('should match a parameterized path with a sub-path', () => {\n expect(\n isPathMatchingRoute({\n currentRoute: '/custom/123/edit',\n path: '/custom/:id',\n }),\n ).toBe(false)\n // pathToRegexp is end-anchored by default, so /custom/:id does not match /custom/123/edit.\n // The literal fallback '/custom/:id' also won't startsWith-match.\n // Parameterized views should use exact: true or include all segments in the pattern.\n })\n\n it('should match when :id captures the full segment including non-slash characters', () => {\n expect(\n isPathMatchingRoute({\n currentRoute: '/custom/123extra',\n path: '/custom/:id',\n }),\n ).toBe(true)\n // :id captures everything up to the next / — '123extra' is a valid :id value\n })\n })\n\n describe('root path / without exact — regression for route shadowing bug', () => {\n it('should match root path against itself', () => {\n expect(isPathMatchingRoute({ currentRoute: '/', path: '/' })).toBe(true)\n })\n\n it('should not match root path against /login', () => {\n expect(isPathMatchingRoute({ currentRoute: '/login', path: '/' })).toBe(false)\n })\n\n it('should not match root path against /collections/posts', () => {\n expect(isPathMatchingRoute({ currentRoute: '/collections/posts', path: '/' })).toBe(false)\n })\n\n it('should not match root path against /collections/posts/123', () => {\n expect(isPathMatchingRoute({ currentRoute: '/collections/posts/123', path: '/' })).toBe(false)\n })\n })\n\n describe('sensitive option', () => {\n it('should match case-insensitively by default', () => {\n expect(\n isPathMatchingRoute({\n currentRoute: '/Dashboard',\n exact: true,\n path: '/dashboard',\n }),\n ).toBe(true)\n })\n\n it('should not match different cases when sensitive is true', () => {\n expect(\n isPathMatchingRoute({\n currentRoute: '/Dashboard',\n exact: true,\n path: '/dashboard',\n sensitive: true,\n }),\n ).toBe(false)\n })\n })\n\n describe('strict option', () => {\n it('should match with or without trailing slash by default', () => {\n expect(\n isPathMatchingRoute({\n currentRoute: '/dashboard/',\n exact: true,\n path: '/dashboard',\n }),\n ).toBe(true)\n })\n\n it('should not match trailing slash mismatch when strict is true', () => {\n expect(\n isPathMatchingRoute({\n currentRoute: '/dashboard/',\n exact: true,\n path: '/dashboard',\n strict: true,\n }),\n ).toBe(false)\n })\n })\n})\n"],"mappings":"AAAA,SAASA,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ;AAErC,SAASC,mBAAmB,QAAQ;AAEpCH,QAAA,CAAS,uBAAuB;EAC9BA,QAAA,CAAS,mBAAmB;IAC1BE,EAAA,CAAG,8CAA8C;MAC/CD,MAAA,CAAOE,mBAAA,CAAoB;QAAEC,YAAA,EAAc;QAAaC,IAAA,EAAMC;MAAU,IAAIC,IAAI,CAAC;IACnF;IAEAL,EAAA,CAAG,iDAAiD;MAClDD,MAAA,CAAOE,mBAAA,CAAoB;QAAEC,YAAA,EAAc;QAAaC,IAAA,EAAM;MAAG,IAAIE,IAAI,CAAC;IAC5E;EACF;EAEAP,QAAA,CAAS,kBAAkB;IACzBE,EAAA,CAAG,iEAAiE;MAClED,MAAA,CACEE,mBAAA,CAAoB;QAAEC,YAAA,EAAc;QAAcI,KAAA,EAAO;QAAMH,IAAA,EAAM;MAAa,IAClFE,IAAI,CAAC;IACT;IAEAL,EAAA,CAAG,sEAAsE;MACvED,MAAA,CACEE,mBAAA,CAAoB;QAAEC,YAAA,EAAc;QAAcI,KAAA,EAAO;QAAMH,IAAA,EAAM;MAAc,IACnFE,IAAI,CAAC;IACT;IAEAL,EAAA,CAAG,4DAA4D;MAC7DD,MAAA,CACEE,mBAAA,CAAoB;QAAEC,YAAA,EAAc;QAAaI,KAAA,EAAO;QAAMH,IAAA,EAAM;MAAa,IACjFE,IAAI,CAAC;IACT;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,EAAA,CAAG,2DAA2D;MAC5DD,MAAA,CACEE,mBAAA,CAAoB;QAClBC,YAAA,EAAc;QACdI,KAAA,EAAO;QACPH,IAAA,EAAM;QACNI,SAAA,EAAW;MACb,IACAF,IAAI,CAAC;IACT;EACF;EAEAP,QAAA,CAAS,iBAAiB;IACxBE,EAAA,CAAG,0DAA0D;MAC3DD,MAAA,CACEE,mBAAA,CAAoB;QAClBC,YAAA,EAAc;QACdI,KAAA,EAAO;QACPH,IAAA,EAAM;MACR,IACAE,IAAI,CAAC;IACT;IAEAL,EAAA,CAAG,gEAAgE;MACjED,MAAA,CACEE,mBAAA,CAAoB;QAClBC,YAAA,EAAc;QACdI,KAAA,EAAO;QACPH,IAAA,EAAM;QACNK,MAAA,EAAQ;MACV,IACAH,IAAI,CAAC;IACT;EACF;AACF","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/views/Version/Restore/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,yBAAyB,EAAE,MAAM,SAAS,CAAA;AAiBpG,OAAO,cAAc,CAAA;AAErB,OAAO,KAA0C,MAAM,OAAO,CAAA;AAK9D,KAAK,KAAK,GAAG;IACX,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,gBAAgB,CAAC,EAAE,sBAAsB,CAAA;IACzC,YAAY,CAAC,EAAE,kBAAkB,CAAA;IACjC,KAAK,EAAE,yBAAyB,CAAC,QAAQ,CAAC,CAAC,UAAU,CAAC,CAAA;IACtD,aAAa,EAAE,MAAM,GAAG,MAAM,CAAA;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,oBAAoB,EAAE,MAAM,CAAA;IAC5B,SAAS,EAAE,MAAM,CAAA;CAClB,CAAA;AAED,eAAO,MAAM,OAAO,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAoHnC,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/views/Version/Restore/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,yBAAyB,EAAE,MAAM,SAAS,CAAA;AAiBpG,OAAO,cAAc,CAAA;AAErB,OAAO,KAA0C,MAAM,OAAO,CAAA;AAK9D,KAAK,KAAK,GAAG;IACX,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,gBAAgB,CAAC,EAAE,sBAAsB,CAAA;IACzC,YAAY,CAAC,EAAE,kBAAkB,CAAA;IACjC,KAAK,EAAE,yBAAyB,CAAC,QAAQ,CAAC,CAAC,UAAU,CAAC,CAAA;IACtD,aAAa,EAAE,MAAM,GAAG,MAAM,CAAA;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,oBAAoB,EAAE,MAAM,CAAA;IAC5B,SAAS,EAAE,MAAM,CAAA;CAClB,CAAA;AAED,eAAO,MAAM,OAAO,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAuHnC,CAAA"}
@@ -45,20 +45,23 @@ export const Restore = ({
45
45
  });
46
46
  const canRestoreAsDraft = status !== 'draft' && collectionConfig?.versions?.drafts;
47
47
  const handleRestore = useCallback(async () => {
48
- let fetchURL = formatAdminURL({
49
- apiRoute,
50
- path: ''
51
- });
48
+ let fetchURL;
52
49
  let redirectURL;
53
50
  if (collectionConfig) {
54
- fetchURL = `${fetchURL}/${collectionConfig.slug}/versions/${versionID}?draft=${draft}`;
51
+ fetchURL = formatAdminURL({
52
+ apiRoute,
53
+ path: `/${collectionConfig.slug}/versions/${versionID}?draft=${draft}`
54
+ });
55
55
  redirectURL = formatAdminURL({
56
56
  adminRoute,
57
57
  path: `/collections/${collectionConfig.slug}/${originalDocID}`
58
58
  });
59
59
  }
60
60
  if (globalConfig) {
61
- fetchURL = `${fetchURL}/globals/${globalConfig.slug}/versions/${versionID}?draft=${draft}`;
61
+ fetchURL = formatAdminURL({
62
+ apiRoute,
63
+ path: `/globals/${globalConfig.slug}/versions/${versionID}?draft=${draft}`
64
+ });
62
65
  redirectURL = formatAdminURL({
63
66
  adminRoute,
64
67
  path: `/globals/${globalConfig.slug}`
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["getTranslation","Button","ConfirmationModal","PopupList","toast","useConfig","useModal","useRouteTransition","useTranslation","requests","useRouter","formatAdminURL","React","Fragment","useCallback","useState","baseClass","modalSlug","Restore","className","collectionConfig","globalConfig","label","originalDocID","status","versionDateFormatted","versionID","config","routes","admin","adminRoute","api","apiRoute","toggleModal","router","i18n","t","draft","setDraft","startRouteTransition","restoreMessage","versionDate","canRestoreAsDraft","versions","drafts","handleRestore","fetchURL","path","redirectURL","slug","res","post","headers","language","json","success","message","push","error","_jsxs","_jsx","filter","Boolean","join","buttonStyle","onClick","size","SubMenuPopupContent","ButtonGroup","body","confirmingLabel","heading","onConfirm"],"sources":["../../../../src/views/Version/Restore/index.tsx"],"sourcesContent":["'use client'\n\nimport type { ClientCollectionConfig, ClientGlobalConfig, SanitizedCollectionConfig } from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport {\n Button,\n ConfirmationModal,\n PopupList,\n toast,\n useConfig,\n useModal,\n useRouteTransition,\n useTranslation,\n} from '@payloadcms/ui'\nimport { requests } from '@payloadcms/ui/shared'\nimport { useRouter } from 'next/navigation.js'\nimport { formatAdminURL } from 'payload/shared'\n\nimport './index.scss'\n\nimport React, { Fragment, useCallback, useState } from 'react'\n\nconst baseClass = 'restore-version'\nconst modalSlug = 'restore-version'\n\ntype Props = {\n className?: string\n collectionConfig?: ClientCollectionConfig\n globalConfig?: ClientGlobalConfig\n label: SanitizedCollectionConfig['labels']['singular']\n originalDocID: number | string\n status?: string\n versionDateFormatted: string\n versionID: string\n}\n\nexport const Restore: React.FC<Props> = ({\n className,\n collectionConfig,\n globalConfig,\n label,\n originalDocID,\n status,\n versionDateFormatted,\n versionID,\n}) => {\n const {\n config: {\n routes: { admin: adminRoute, api: apiRoute },\n },\n } = useConfig()\n\n const { toggleModal } = useModal()\n const router = useRouter()\n const { i18n, t } = useTranslation()\n const [draft, setDraft] = useState(false)\n const { startRouteTransition } = useRouteTransition()\n\n const restoreMessage = t(\n globalConfig ? 'version:aboutToRestoreGlobal' : 'version:aboutToRestore',\n {\n label: getTranslation(label, i18n),\n versionDate: versionDateFormatted,\n },\n )\n\n const canRestoreAsDraft = status !== 'draft' && collectionConfig?.versions?.drafts\n\n const handleRestore = useCallback(async () => {\n let fetchURL = formatAdminURL({\n apiRoute,\n path: '',\n })\n let redirectURL: string\n\n if (collectionConfig) {\n fetchURL = `${fetchURL}/${collectionConfig.slug}/versions/${versionID}?draft=${draft}`\n redirectURL = formatAdminURL({\n adminRoute,\n path: `/collections/${collectionConfig.slug}/${originalDocID}`,\n })\n }\n\n if (globalConfig) {\n fetchURL = `${fetchURL}/globals/${globalConfig.slug}/versions/${versionID}?draft=${draft}`\n redirectURL = formatAdminURL({\n adminRoute,\n path: `/globals/${globalConfig.slug}`,\n })\n }\n\n const res = await requests.post(fetchURL, {\n headers: {\n 'Accept-Language': i18n.language,\n },\n })\n\n if (res.status === 200) {\n const json = await res.json()\n toast.success(json.message)\n return startRouteTransition(() => router.push(redirectURL))\n } else {\n toast.error(t('version:problemRestoringVersion'))\n }\n }, [\n apiRoute,\n collectionConfig,\n globalConfig,\n i18n.language,\n versionID,\n draft,\n adminRoute,\n originalDocID,\n startRouteTransition,\n router,\n t,\n ])\n\n return (\n <Fragment>\n <div className={[baseClass, className].filter(Boolean).join(' ')}>\n <Button\n buttonStyle=\"primary\"\n className={[canRestoreAsDraft && `${baseClass}__restore-as-draft-button`]\n .filter(Boolean)\n .join(' ')}\n onClick={() => toggleModal(modalSlug)}\n size=\"xsmall\"\n SubMenuPopupContent={\n canRestoreAsDraft\n ? () => (\n <PopupList.ButtonGroup>\n <PopupList.Button onClick={() => [setDraft(true), toggleModal(modalSlug)]}>\n {t('version:restoreAsDraft')}\n </PopupList.Button>\n </PopupList.ButtonGroup>\n )\n : null\n }\n >\n {t('version:restoreThisVersion')}\n </Button>\n </div>\n <ConfirmationModal\n body={restoreMessage}\n confirmingLabel={t('version:restoring')}\n heading={t('version:confirmVersionRestoration')}\n modalSlug={modalSlug}\n onConfirm={handleRestore}\n />\n </Fragment>\n )\n}\n"],"mappings":"AAAA;;;AAIA,SAASA,cAAc,QAAQ;AAC/B,SACEC,MAAM,EACNC,iBAAiB,EACjBC,SAAS,EACTC,KAAK,EACLC,SAAS,EACTC,QAAQ,EACRC,kBAAkB,EAClBC,cAAc,QACT;AACP,SAASC,QAAQ,QAAQ;AACzB,SAASC,SAAS,QAAQ;AAC1B,SAASC,cAAc,QAAQ;AAI/B,OAAOC,KAAA,IAASC,QAAQ,EAAEC,WAAW,EAAEC,QAAQ,QAAQ;AAEvD,MAAMC,SAAA,GAAY;AAClB,MAAMC,SAAA,GAAY;AAalB,OAAO,MAAMC,OAAA,GAA2BA,CAAC;EACvCC,SAAS;EACTC,gBAAgB;EAChBC,YAAY;EACZC,KAAK;EACLC,aAAa;EACbC,MAAM;EACNC,oBAAoB;EACpBC;AAAS,CACV;EACC,MAAM;IACJC,MAAA,EAAQ;MACNC,MAAA,EAAQ;QAAEC,KAAA,EAAOC,UAAU;QAAEC,GAAA,EAAKC;MAAQ;IAAE;EAC7C,CACF,GAAG3B,SAAA;EAEJ,MAAM;IAAE4B;EAAW,CAAE,GAAG3B,QAAA;EACxB,MAAM4B,MAAA,GAASxB,SAAA;EACf,MAAM;IAAEyB,IAAI;IAAEC;EAAC,CAAE,GAAG5B,cAAA;EACpB,MAAM,CAAC6B,KAAA,EAAOC,QAAA,CAAS,GAAGvB,QAAA,CAAS;EACnC,MAAM;IAAEwB;EAAoB,CAAE,GAAGhC,kBAAA;EAEjC,MAAMiC,cAAA,GAAiBJ,CAAA,CACrBf,YAAA,GAAe,iCAAiC,0BAChD;IACEC,KAAA,EAAOtB,cAAA,CAAesB,KAAA,EAAOa,IAAA;IAC7BM,WAAA,EAAahB;EACf;EAGF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A,EACAP,UAAA,EACAP,aAAA,EACAgB,oBAAA,EACAL,MAAA,EACAE,CAAA,CACD;EAED,oBACEuB,KAAA,CAAC9C,QAAA;4BACC+C,IAAA,CAAC;MAAIzC,SAAA,EAAW,CAACH,SAAA,EAAWG,SAAA,CAAU,CAAC0C,MAAM,CAACC,OAAA,EAASC,IAAI,CAAC;gBAC1D,aAAAH,IAAA,CAAC3D,MAAA;QACC+D,WAAA,EAAY;QACZ7C,SAAA,EAAW,CAACuB,iBAAA,IAAqB,GAAG1B,SAAA,2BAAoC,CAAC,CACtE6C,MAAM,CAACC,OAAA,EACPC,IAAI,CAAC;QACRE,OAAA,EAASA,CAAA,KAAMhC,WAAA,CAAYhB,SAAA;QAC3BiD,IAAA,EAAK;QACLC,mBAAA,EACEzB,iBAAA,GACI,mBACEkB,IAAA,CAACzD,SAAA,CAAUiE,WAAW;oBACpB,aAAAR,IAAA,CAACzD,SAAA,CAAUF,MAAM;YAACgE,OAAA,EAASA,CAAA,KAAM,CAAC3B,QAAA,CAAS,OAAOL,WAAA,CAAYhB,SAAA,EAAW;sBACtEmB,CAAA,CAAE;;aAIT;kBAGLA,CAAA,CAAE;;qBAGPwB,IAAA,CAAC1D,iBAAA;MACCmE,IAAA,EAAM7B,cAAA;MACN8B,eAAA,EAAiBlC,CAAA,CAAE;MACnBmC,OAAA,EAASnC,CAAA,CAAE;MACXnB,SAAA,EAAWA,SAAA;MACXuD,SAAA,EAAW3B;;;AAInB","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["getTranslation","Button","ConfirmationModal","PopupList","toast","useConfig","useModal","useRouteTransition","useTranslation","requests","useRouter","formatAdminURL","React","Fragment","useCallback","useState","baseClass","modalSlug","Restore","className","collectionConfig","globalConfig","label","originalDocID","status","versionDateFormatted","versionID","config","routes","admin","adminRoute","api","apiRoute","toggleModal","router","i18n","t","draft","setDraft","startRouteTransition","restoreMessage","versionDate","canRestoreAsDraft","versions","drafts","handleRestore","fetchURL","redirectURL","path","slug","res","post","headers","language","json","success","message","push","error","_jsxs","_jsx","filter","Boolean","join","buttonStyle","onClick","size","SubMenuPopupContent","ButtonGroup","body","confirmingLabel","heading","onConfirm"],"sources":["../../../../src/views/Version/Restore/index.tsx"],"sourcesContent":["'use client'\n\nimport type { ClientCollectionConfig, ClientGlobalConfig, SanitizedCollectionConfig } from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport {\n Button,\n ConfirmationModal,\n PopupList,\n toast,\n useConfig,\n useModal,\n useRouteTransition,\n useTranslation,\n} from '@payloadcms/ui'\nimport { requests } from '@payloadcms/ui/shared'\nimport { useRouter } from 'next/navigation.js'\nimport { formatAdminURL } from 'payload/shared'\n\nimport './index.scss'\n\nimport React, { Fragment, useCallback, useState } from 'react'\n\nconst baseClass = 'restore-version'\nconst modalSlug = 'restore-version'\n\ntype Props = {\n className?: string\n collectionConfig?: ClientCollectionConfig\n globalConfig?: ClientGlobalConfig\n label: SanitizedCollectionConfig['labels']['singular']\n originalDocID: number | string\n status?: string\n versionDateFormatted: string\n versionID: string\n}\n\nexport const Restore: React.FC<Props> = ({\n className,\n collectionConfig,\n globalConfig,\n label,\n originalDocID,\n status,\n versionDateFormatted,\n versionID,\n}) => {\n const {\n config: {\n routes: { admin: adminRoute, api: apiRoute },\n },\n } = useConfig()\n\n const { toggleModal } = useModal()\n const router = useRouter()\n const { i18n, t } = useTranslation()\n const [draft, setDraft] = useState(false)\n const { startRouteTransition } = useRouteTransition()\n\n const restoreMessage = t(\n globalConfig ? 'version:aboutToRestoreGlobal' : 'version:aboutToRestore',\n {\n label: getTranslation(label, i18n),\n versionDate: versionDateFormatted,\n },\n )\n\n const canRestoreAsDraft = status !== 'draft' && collectionConfig?.versions?.drafts\n\n const handleRestore = useCallback(async () => {\n let fetchURL: string\n let redirectURL: string\n\n if (collectionConfig) {\n fetchURL = formatAdminURL({\n apiRoute,\n path: `/${collectionConfig.slug}/versions/${versionID}?draft=${draft}`,\n })\n redirectURL = formatAdminURL({\n adminRoute,\n path: `/collections/${collectionConfig.slug}/${originalDocID}`,\n })\n }\n\n if (globalConfig) {\n fetchURL = formatAdminURL({\n apiRoute,\n path: `/globals/${globalConfig.slug}/versions/${versionID}?draft=${draft}`,\n })\n redirectURL = formatAdminURL({\n adminRoute,\n path: `/globals/${globalConfig.slug}`,\n })\n }\n\n const res = await requests.post(fetchURL, {\n headers: {\n 'Accept-Language': i18n.language,\n },\n })\n\n if (res.status === 200) {\n const json = await res.json()\n toast.success(json.message)\n return startRouteTransition(() => router.push(redirectURL))\n } else {\n toast.error(t('version:problemRestoringVersion'))\n }\n }, [\n apiRoute,\n collectionConfig,\n globalConfig,\n i18n.language,\n versionID,\n draft,\n adminRoute,\n originalDocID,\n startRouteTransition,\n router,\n t,\n ])\n\n return (\n <Fragment>\n <div className={[baseClass, className].filter(Boolean).join(' ')}>\n <Button\n buttonStyle=\"primary\"\n className={[canRestoreAsDraft && `${baseClass}__restore-as-draft-button`]\n .filter(Boolean)\n .join(' ')}\n onClick={() => toggleModal(modalSlug)}\n size=\"xsmall\"\n SubMenuPopupContent={\n canRestoreAsDraft\n ? () => (\n <PopupList.ButtonGroup>\n <PopupList.Button onClick={() => [setDraft(true), toggleModal(modalSlug)]}>\n {t('version:restoreAsDraft')}\n </PopupList.Button>\n </PopupList.ButtonGroup>\n )\n : null\n }\n >\n {t('version:restoreThisVersion')}\n </Button>\n </div>\n <ConfirmationModal\n body={restoreMessage}\n confirmingLabel={t('version:restoring')}\n heading={t('version:confirmVersionRestoration')}\n modalSlug={modalSlug}\n onConfirm={handleRestore}\n />\n </Fragment>\n )\n}\n"],"mappings":"AAAA;;;AAIA,SAASA,cAAc,QAAQ;AAC/B,SACEC,MAAM,EACNC,iBAAiB,EACjBC,SAAS,EACTC,KAAK,EACLC,SAAS,EACTC,QAAQ,EACRC,kBAAkB,EAClBC,cAAc,QACT;AACP,SAASC,QAAQ,QAAQ;AACzB,SAASC,SAAS,QAAQ;AAC1B,SAASC,cAAc,QAAQ;AAI/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AA,KAAMhC,WAAA,CAAYhB,SAAA;QAC3BiD,IAAA,EAAK;QACLC,mBAAA,EACEzB,iBAAA,GACI,mBACEkB,IAAA,CAACzD,SAAA,CAAUiE,WAAW;oBACpB,aAAAR,IAAA,CAACzD,SAAA,CAAUF,MAAM;YAACgE,OAAA,EAASA,CAAA,KAAM,CAAC3B,QAAA,CAAS,OAAOL,WAAA,CAAYhB,SAAA,EAAW;sBACtEmB,CAAA,CAAE;;aAIT;kBAGLA,CAAA,CAAE;;qBAGPwB,IAAA,CAAC1D,iBAAA;MACCmE,IAAA,EAAM7B,cAAA;MACN8B,eAAA,EAAiBlC,CAAA,CAAE;MACnBmC,OAAA,EAASnC,CAAA,CAAE;MACXnB,SAAA,EAAWA,SAAA;MACXuD,SAAA,EAAW3B;;;AAInB","ignoreList":[]}
@@ -77,10 +77,6 @@ export const withPayload = (nextConfig = {}, options = {}) => {
77
77
  ...(nextConfig.outputFileTracingExcludes || {}),
78
78
  '**/*': [...(nextConfig.outputFileTracingExcludes?.['**/*'] || []), 'drizzle-kit', 'drizzle-kit/api']
79
79
  },
80
- outputFileTracingIncludes: {
81
- ...(nextConfig.outputFileTracingIncludes || {}),
82
- '**/*': [...(nextConfig.outputFileTracingIncludes?.['**/*'] || []), '@libsql/client']
83
- },
84
80
  turbopack: {
85
81
  ...(nextConfig.turbopack || {})
86
82
  },
@@ -194,6 +190,9 @@ export const withPayload = (nextConfig = {}, options = {}) => {
194
190
  process.env.NEXT_BASE_PATH = nextConfig.basePath;
195
191
  baseConfig.env.NEXT_BASE_PATH = nextConfig.basePath;
196
192
  }
193
+ const trailingSlash = nextConfig.trailingSlash === true ? 'true' : 'false';
194
+ process.env.NEXT_TRAILING_SLASH = trailingSlash;
195
+ baseConfig.env.NEXT_TRAILING_SLASH = trailingSlash;
197
196
  if (!supportsTurbopackBuild) {
198
197
  return withPayloadLegacy(baseConfig);
199
198
  } else {