@uniweb/core 0.2.0 → 0.2.1
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 +2 -2
- package/src/website.js +22 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uniweb/core",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "Core classes for the Uniweb platform - Uniweb, Website, Page, Block",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"jest": "^29.7.0"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@uniweb/semantic-parser": "1.0.
|
|
33
|
+
"@uniweb/semantic-parser": "1.0.13"
|
|
34
34
|
},
|
|
35
35
|
"scripts": {
|
|
36
36
|
"test": "node --experimental-vm-modules node_modules/jest/bin/jest.js"
|
package/src/website.js
CHANGED
|
@@ -969,8 +969,18 @@ export default class Website {
|
|
|
969
969
|
|
|
970
970
|
// Check each versioned scope to see if route falls within it
|
|
971
971
|
for (const scope of Object.keys(this.versionedScopes)) {
|
|
972
|
-
// Route matches scope exactly
|
|
973
|
-
if (normalizedRoute === scope
|
|
972
|
+
// Route matches scope exactly
|
|
973
|
+
if (normalizedRoute === scope) {
|
|
974
|
+
return scope
|
|
975
|
+
}
|
|
976
|
+
|
|
977
|
+
// Root scope matches all routes starting with /
|
|
978
|
+
if (scope === '/') {
|
|
979
|
+
if (normalizedRoute.startsWith('/') || normalizedRoute === '') {
|
|
980
|
+
return scope
|
|
981
|
+
}
|
|
982
|
+
} else if (normalizedRoute.startsWith(scope + '/')) {
|
|
983
|
+
// Route is a child of this scope
|
|
974
984
|
return scope
|
|
975
985
|
}
|
|
976
986
|
}
|
|
@@ -1060,7 +1070,10 @@ export default class Website {
|
|
|
1060
1070
|
if (!targetVersionInfo) return null
|
|
1061
1071
|
|
|
1062
1072
|
// Extract the path within the scope (after scope and any version prefix)
|
|
1063
|
-
|
|
1073
|
+
// For root scope ('/'), keep the full path; otherwise slice off the scope
|
|
1074
|
+
const afterScope = scope === '/'
|
|
1075
|
+
? currentRoute
|
|
1076
|
+
: currentRoute.slice(scope.length) // e.g., '/getting-started' or '/v1/getting-started'
|
|
1064
1077
|
|
|
1065
1078
|
// Check if current route has a version prefix
|
|
1066
1079
|
let pathWithinVersion = afterScope
|
|
@@ -1076,9 +1089,13 @@ export default class Website {
|
|
|
1076
1089
|
// Build target URL
|
|
1077
1090
|
// Latest version has no prefix, others have /vN prefix
|
|
1078
1091
|
if (targetVersionInfo.latest) {
|
|
1079
|
-
|
|
1092
|
+
// For root scope, return path directly; otherwise prepend scope
|
|
1093
|
+
return scope === '/' ? pathWithinVersion : scope + pathWithinVersion
|
|
1080
1094
|
} else {
|
|
1081
|
-
|
|
1095
|
+
// For root scope: /v1/path; otherwise: scope/v1/path
|
|
1096
|
+
return scope === '/'
|
|
1097
|
+
? '/' + targetVersion + pathWithinVersion
|
|
1098
|
+
: scope + '/' + targetVersion + pathWithinVersion
|
|
1082
1099
|
}
|
|
1083
1100
|
}
|
|
1084
1101
|
|