stx-router 0.2.317 → 0.2.319
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/dist/file-router.js +14 -2
- package/dist/types.d.ts +1 -0
- package/package.json +1 -1
package/dist/file-router.js
CHANGED
|
@@ -41,10 +41,22 @@ export class Router {
|
|
|
41
41
|
const rawDirs = config.pagesDirs && config.pagesDirs.length > 0 ? config.pagesDirs : [config.pagesDir || "pages"];
|
|
42
42
|
this.pagesDirs = rawDirs.map((d) => path.resolve(baseDir, d));
|
|
43
43
|
this.pagesDir = this.pagesDirs[0];
|
|
44
|
-
const extensions = config.extensions || [".stx"],
|
|
44
|
+
const extensions = config.extensions || [".stx"], canonical = (entry) => {
|
|
45
|
+
const resolved = path.resolve(baseDir, entry);
|
|
46
|
+
try {
|
|
47
|
+
return fs.realpathSync(resolved);
|
|
48
|
+
} catch {
|
|
49
|
+
return resolved;
|
|
50
|
+
}
|
|
51
|
+
}, excluded = (config.exclude ?? []).filter((entry) => typeof entry === "string" && entry.trim() !== "").map(canonical), isExcluded = (file) => {
|
|
52
|
+
if (excluded.length === 0)
|
|
53
|
+
return !1;
|
|
54
|
+
const real = canonical(file);
|
|
55
|
+
return excluded.some((root) => real === root || real.startsWith(`${root}${path.sep}`));
|
|
56
|
+
}, seenPatterns = new Set;
|
|
45
57
|
this.routes = [];
|
|
46
58
|
for (const dir of this.pagesDirs) {
|
|
47
|
-
const files = scanDirectory(dir, extensions), localPatterns = new Map;
|
|
59
|
+
const files = scanDirectory(dir, extensions).filter((file) => !isExcluded(file)), localPatterns = new Map;
|
|
48
60
|
for (const filePath of files) {
|
|
49
61
|
const pattern = filePathToPattern(filePath, dir), identity = config.pagesDirs ? pattern.replace(/:[\w]+/g, ":param") : pattern;
|
|
50
62
|
if (config.pagesDirs && localPatterns.has(identity))
|
package/dist/types.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "stx-router",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.319",
|
|
5
5
|
"description": "File-based router for STX — .stx template discovery, nested layouts, typed route params, middleware, and client-side SPA navigation.",
|
|
6
6
|
"author": "Chris Breuer <chris@stacksjs.org>",
|
|
7
7
|
"license": "MIT",
|