filesystem-routing 0.4.1 → 0.4.2

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.
@@ -12,8 +12,9 @@ export function routePathFromFile(routeFile) {
12
12
  const routePath = routeFile
13
13
  // remove the initial slash
14
14
  .slice(1)
15
- // only strip a whole `index` segment, not a name that merely ends in "index" (e.g. `reindex`)
16
- .replace(/(^|\/)index$/, "$1")
15
+ // only strip a whole `index` segment, not a name that merely ends in "index" (e.g. `reindex`);
16
+ // group prefixes such as SolidBase's `(0)index` ordering stay for the adapters to strip
17
+ .replace(/(^|\/)((?:\([^/()]*\))*)index$/, "$1$2")
17
18
  .replace(/\[([^/]+)\]/g, (_, m) => {
18
19
  if (m.length > 3 && m.startsWith("...")) {
19
20
  return `*${m.slice(3)}`;
package/dist/tree.js CHANGED
@@ -20,8 +20,10 @@ export function buildRouteTree(entries) {
20
20
  }
21
21
  processRoute(parentRoute.children || (parentRoute.children = []), route, id.slice(parentRoute.id.length));
22
22
  }
23
+ // Ties break by UTF-16 code unit, as the scan sorts files, not by
24
+ // `localeCompare`: the generated output must not depend on the machine's locale.
23
25
  return [...entries]
24
- .sort((a, b) => (a.path.length - b.path.length) || a.path.localeCompare(b.path))
26
+ .sort((a, b) => a.path.length - b.path.length || (a.path < b.path ? -1 : a.path > b.path ? 1 : 0))
25
27
  .reduce((routes, route) => {
26
28
  processRoute(routes, route, route.path);
27
29
  return routes;
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "filesystem-routing",
3
3
  "description": "Router-neutral file-system routing: scans a route directory into a neutral route manifest with pluggable conventions and delivery adapters",
4
4
  "license": "MIT",
5
- "version": "0.4.1",
5
+ "version": "0.4.2",
6
6
  "author": "Ryan Carniato",
7
7
  "homepage": "https://github.com/solidjs/filesystem-routing#readme",
8
8
  "repository": {