@uniweb/core 0.2.3 → 0.2.4
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.
- package/package.json +1 -1
- package/src/website.js +11 -7
package/package.json
CHANGED
package/src/website.js
CHANGED
|
@@ -201,18 +201,22 @@ export default class Website {
|
|
|
201
201
|
* @returns {Page|undefined}
|
|
202
202
|
*/
|
|
203
203
|
getPage(route) {
|
|
204
|
+
// Normalize trailing slashes for consistent matching
|
|
205
|
+
// '/about/' and '/about' should match the same page
|
|
206
|
+
const normalizedRoute = route === '/' ? '/' : route.replace(/\/$/, '')
|
|
207
|
+
|
|
204
208
|
// Priority 1: Exact match on actual route
|
|
205
|
-
const exactMatch = this.pages.find((page) => page.route ===
|
|
209
|
+
const exactMatch = this.pages.find((page) => page.route === normalizedRoute)
|
|
206
210
|
if (exactMatch) return exactMatch
|
|
207
211
|
|
|
208
212
|
// Priority 2: Index page nav route match
|
|
209
|
-
const indexMatch = this.pages.find((page) => page.isIndex && page.getNavRoute() ===
|
|
213
|
+
const indexMatch = this.pages.find((page) => page.isIndex && page.getNavRoute() === normalizedRoute)
|
|
210
214
|
if (indexMatch) return indexMatch
|
|
211
215
|
|
|
212
216
|
// Priority 3: Dynamic route pattern matching
|
|
213
217
|
// Check cache first
|
|
214
|
-
if (this._dynamicPageCache.has(
|
|
215
|
-
return this._dynamicPageCache.get(
|
|
218
|
+
if (this._dynamicPageCache.has(normalizedRoute)) {
|
|
219
|
+
return this._dynamicPageCache.get(normalizedRoute)
|
|
216
220
|
}
|
|
217
221
|
|
|
218
222
|
// Try to match against dynamic route patterns
|
|
@@ -220,13 +224,13 @@ export default class Website {
|
|
|
220
224
|
// Check if this is a dynamic page (has :param in route)
|
|
221
225
|
if (!page.route.includes(':')) continue
|
|
222
226
|
|
|
223
|
-
const match = this._matchDynamicRoute(page.route,
|
|
227
|
+
const match = this._matchDynamicRoute(page.route, normalizedRoute)
|
|
224
228
|
if (match) {
|
|
225
229
|
// Create a dynamic page instance with the concrete route and params
|
|
226
|
-
const dynamicPage = this._createDynamicPage(page,
|
|
230
|
+
const dynamicPage = this._createDynamicPage(page, normalizedRoute, match.params)
|
|
227
231
|
if (dynamicPage) {
|
|
228
232
|
// Cache for future requests
|
|
229
|
-
this._dynamicPageCache.set(
|
|
233
|
+
this._dynamicPageCache.set(normalizedRoute, dynamicPage)
|
|
230
234
|
return dynamicPage
|
|
231
235
|
}
|
|
232
236
|
}
|