zyket 1.1.9 → 1.1.10
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
CHANGED
|
@@ -185,9 +185,21 @@ module.exports = class Express extends Service {
|
|
|
185
185
|
routePath = routePath.replaceAll('index', '/');
|
|
186
186
|
routePath = routePath.replaceAll('//', '/');
|
|
187
187
|
routePath = routePath.replace(/\[([^\]]+)\]/g, ':$1');
|
|
188
|
-
|
|
188
|
+
|
|
189
189
|
return new route(routePath);
|
|
190
190
|
});
|
|
191
|
+
|
|
192
|
+
routes.sort((a, b) => {
|
|
193
|
+
const aSegments = a.path.split('/').filter(Boolean);
|
|
194
|
+
const bSegments = b.path.split('/').filter(Boolean);
|
|
195
|
+
const aDynCount = aSegments.filter(s => s.startsWith(':')).length;
|
|
196
|
+
const bDynCount = bSegments.filter(s => s.startsWith(':')).length;
|
|
197
|
+
if (aDynCount !== bDynCount) return aDynCount - bDynCount;
|
|
198
|
+
const aFirstDyn = aSegments.findIndex(s => s.startsWith(':'));
|
|
199
|
+
const bFirstDyn = bSegments.findIndex(s => s.startsWith(':'));
|
|
200
|
+
return (bFirstDyn === -1 ? Infinity : bFirstDyn) - (aFirstDyn === -1 ? Infinity : aFirstDyn);
|
|
201
|
+
});
|
|
202
|
+
|
|
191
203
|
return routes;
|
|
192
204
|
}
|
|
193
205
|
|