Last active
November 14, 2021 20:45
-
-
Save cj/a9c967c517c37aad09e41aa2e9779c25 to your computer and use it in GitHub Desktop.
Krabs - allow common pages
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/node_modules/krabs/dist/express-krabs/index.js b/node_modules/krabs/dist/express-krabs/index.js | |
index 493254f..fdd3318 100644 | |
--- a/node_modules/krabs/dist/express-krabs/index.js | |
+++ b/node_modules/krabs/dist/express-krabs/index.js | |
@@ -86,7 +86,7 @@ function krabs(req, res, handle, app, config) { | |
} | |
return [2 /*return*/]; | |
} | |
- route = resolve_1["default"](tenant.name, String(pathname)); | |
+ route = resolve_1["default"](tenant.name, String(pathname), tenant.commonPages); | |
if (route) { | |
// @ts-ignore | |
req.tenant = tenant; | |
diff --git a/node_modules/krabs/dist/utils/routes/resolve.js b/node_modules/krabs/dist/utils/routes/resolve.js | |
index 14995ef..e886a9b 100644 | |
--- a/node_modules/krabs/dist/utils/routes/resolve.js | |
+++ b/node_modules/krabs/dist/utils/routes/resolve.js | |
@@ -1,8 +1,18 @@ | |
"use strict"; | |
+var path = require("path"); | |
+var fs = require("fs"); | |
+ | |
exports.__esModule = true; | |
exports.resolveRoutes = void 0; | |
-function resolveRoutes(tenantName, pathname) { | |
- return pathname === '/' ? "/" + tenantName : "/" + tenantName + pathname; | |
+function resolveRoutes(tenantName, pathname, rawCommonPages) { | |
+ var commonPages = !!rawCommonPages | |
+ var pageExistsInTenant = fs.existsSync(path.join(process.cwd(), 'pages', tenantName, `${pathname}.js`)); | |
+ | |
+ if(commonPages && !pageExistsInTenant) { | |
+ return `${pathname}` | |
+ } | |
+ | |
+ return pathname === '/' ? `/${tenantName}` : `/${tenantName}${pathname}`; | |
} | |
exports.resolveRoutes = resolveRoutes; | |
exports["default"] = resolveRoutes; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment